AJAX = asynchronous JavaScript and XML.
AJAX is a technique for creating fast Dynamic Web pages.
AJAX allows Web pages to be updated asynchronously by exchanging small amounts of data in the background with the server. This means it is possible to update part of a Web page without overloading the entire page.
You must create a XMLHttpRequest object before you implement Ajax. If you do not support the browser that created the object, you need to create activexobject. The following are the specific methods:
var xmlHttp;
function Createxmlhttprequest ()
{
if (window). ActiveXObject) {
xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
}
else if
(window. XMLHttpRequest)
{
xmlhttp=new xmlhttprequest ();
}
(1) Use the XMLHTTP created above to implement the simplest Ajax GET request:
function doget (URL)
{
//Note the best use of encodeURI when passing parameter values to prevent garbled
createxmlhttprequest ();
Xmlhttp.open ("get", url);
Xmlhttp.send (null);
Xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readystate = 4) && (Xmlhttp.status = 200)) { C22/>alert (' success ');
}
else
{
alert (' fail ');
}
}
(2) Use the XMLHTTP created above to implement the simplest Ajax POST request:
function DoPost (url,data)
{
//Note the best use of encodeURI when passing parameter values to prevent garbled
createxmlhttprequest ();
Xmlhttp.open ("POST", url);
Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Xmlhttp.send (data);
Xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readystate = 4) && (Xmlhttp.status = 200)) c11/>{
alert (' success ');
}
else
{
alert (' fail ');
}
}
The above content is small to introduce the JavaScript AJAX implementation of the example code, I hope to help you, in the use of the process found any questions welcome to my message, small series will promptly reply to everyone. In this small series thank you very much for the cloud Habitat Community website support, I believe we will do better!