How Ajax cancels the processing of pending requests _php Tutorial

Source: Internet
Author: User
When we switch tabs, if we are using AJAX technology, we will encounter the following situation: Click the TAB1 option, the server sends an AJAX request to get the content data of this option TAB1. If the request is being processed and you click the TAB2 option in the process and send a new request, the server now has two requests pending. The result of the page is that when the data content is displayed, the content data for the TAB1 option is displayed first, and then the TAB2 option is displayed. In this case, we should cancel the TAB1 pending request, allowing only the processing of the current (TAB2) request to create a new index.html code as follows:
Copy CodeThe code is as follows:






    • Tab 1

    • TAB 2

    • Tab 3






Then create a 4.php file code as follows:
Copy CodeThe code is as follows:
Sleep (1);
if (Isset ($_get[' What '))
{
Switch ($_get[' what ')
{
Case 1:echo ' 111111111111111 ';
Break
Case 2:
Echo ' 22222222222222222 ';
Break
Case 3:
Echo ' 33333333333333333 ';
Break
Default:echo ' no content ';
}
}

?>


Also to build a folder JS,
Put a jquery-1.4.4.min.js file inside,
Not necessarily the 1.4.4 version;
Build a folder img,
Inside put a loading.gif wait picture will index.html + 4.php + JS (folder) +img (folder) put in the WWW file, run with the browser

http://www.bkjia.com/PHPjc/326729.html www.bkjia.com true http://www.bkjia.com/PHPjc/326729.html techarticle When we switch tabs, if we are using AJAX technology, we will encounter the following situation: Click the TAB1 option, the server sends an AJAX request to get the content data of this option TAB1. If ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.