AJAX interaction data

 

ajax definition: it can be synchronous / asynchronous server communication is one of technology

ajax language support: JavaScript

ajax features: page does not refresh

ajax benefits: 1, the user experience is good

                 2, save bandwidth

The use of native ajax

1, the object creating ajax var xhr = newXMLHttpRequest ();

2, sending a request for service 

Create a request: xhr.open ( "get", 'URL');

Send Request: xhr.send (null);

3, to accept the server returns information

Set Event: xhr.onreadystaechange = function () {

if(xhr.readystate==4){

document.body.innerhtml += xhr.responsetext;

}

}

4, get and post

Different: a, the number of servers to deliver, get a 2k, post unlimited

          b, post security

          c, different forms of data transmission, get back in the transfer function of the address in the request string, post the data to form the form out request to the server in the form of xml

jQuery's ajax grammar

.ajax $ ({ 
    of the type:. "prescribed type of request (GET or POST)", 
    url:. "sending the request URL specified default is the current page", 
    the Data: { 
        "provide for the data sent to the server": "" 
    }, 
    success: function () { 
        . "function when a request to run a successful"; 
    } 
})

  

ajax definition: it can be synchronous / asynchronous server communication is one of technology

ajax language support: JavaScript

ajax features: page does not refresh

ajax benefits: 1, the user experience is good

                 2, save bandwidth

The use of native ajax

1, the object creating ajax var xhr = newXMLHttpRequest ();

2, sending a request for service 

Create a request: xhr.open ( "get", 'URL');

Send Request: xhr.send (null);

3, to accept the server returns information

Set Event: xhr.onreadystaechange = function () {

if(xhr.readystate==4){

document.body.innerhtml += xhr.responsetext;

}

}

4, get and post

Different: a, the number of servers to deliver, get a 2k, post unlimited

          b, post security

          c, different forms of data transmission, get back in the transfer function of the address in the request string, post the data to form the form out request to the server in the form of xml

jQuery's ajax grammar

.ajax $ ({ 
    of the type:. "prescribed type of request (GET or POST)", 
    url:. "sending the request URL specified default is the current page", 
    the Data: { 
        "provide for the data sent to the server": "" 
    }, 
    success: function () { 
        . "function when a request to run a successful"; 
    } 
})

  

Guess you like

Origin www.cnblogs.com/gaojian910/p/11264640.html