Ajax page Tip Processing

Source: Internet
Author: User
Ajax| page

Ajax page Tip Processing

Phenomenon: Because the existing system must be implemented in B/s real-time data display and tip display, when the mouse moved to a

, the system uses AJAX way to the background data. In the process of fetching data, it is often found that the system process pauses, the main performance is: All system process pauses, mouse does not work.

Reason:

The original system adopted a synchronous way to submit, the code is as follows:

var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlHTTP. Open ("Post", "testto.jsp", false);/sync
xmlHTTP. Send (DOC);
return xmlhttp.responsetext;

Change the above request to asynchronous, namely the XMLHTTP. Open ("Post", "testto.jsp", true), and a JavaScript script error occurs.

Solution:

var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlHTTP. Open ("Post", "maptipto.jsp", true);
xmlHTTP. Send (DOC);
Xmlhttp.onreadystatechange=function () {//callback function
if (xmlhttp.readystate==4&&) {
if (xmlhttp.status==200) {
var text = Xmlhttp.responsetext;
Todo handler function
Dosometing ();
} else {
Alert ("You are requesting an exception.) ");
}

} else{
Prompt function
document.getElementById ("Messagediv"). Innerhtml= "Read the data, please wait ...";
}
}

Note: Process the request in the form of a callback function. The handler function should be placed inside the callback function and should not be placed outside the callback function




Related Article

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.