Ajax asynchronous Commit (Frontend)

Source: Internet
Author: User

/*ajax Asynchronous Commit */
/*1. Declaring an AJAX global variable */
var ajaxrequest;
function Checkajax () {
/*2. Creating xmlhttprequest*/
Ajaxrequest=new XMLHttpRequest ();
/*3. Configuring the Request Object */
var url= "user.do?uname=" +$ ("uname"). Value () + "times=" +new Date (). getmilliseconds ();
/* Solve garbled problem, backstage with Urldecoder.decode (uname,, "" utf-8) */
Url=encodeuri (URL);
Url=encodeuri (URL);
/* Turn on request */
/*/!*post Submit the code below *!/
Ajaxrequest.setrequestheader ("Content-type", "appplication/x-www-form-urlencoded"); */
Ajaxrequest.open ("GET", url,true);
/*4. Preparing the Send status--ajax*/
Ajaxrequest.onreadystatechange=function () {
/* Judge status as Ajax, normal response */
if (ajaxrequest.readystate==4&&ajaxrequest.status==200) {
$ ("result"). Innerhtml=ajaxrequest.responsetext;
}
}
/*get method Send (NULL) Fill Null,post method fill variable send (num) */
Ajaxrequest.send (NULL);
}


}

Ajax asynchronous Commit (Frontend)

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.