Talking about the new page without refreshing ajax technology, talking about page refreshing ajax
Currently, most websites use ajax to perform page refreshing.
What is no refreshing: ajax can achieve data interaction between pages and the background, and users cannot feel any page refreshing at all. This is the refreshing of AJAX.
Ajax implementation:
You can encapsulate ajax to facilitate calling of each page:
Function MyAjax (type, url, callBack, data, dataType, asyncType)
{
If (dataType = null) {dataType = "text ";}
If (asyncType = null) {asyncType = true ;}
$. Ajax ({
Type: type, // post or get
Url: url, // it is best to add a url + Math. random () to ensure that the page of each request is regarded as different by the browser.
Data: data, // here is the parameter to be passed, in the format of data: "{paraName: paraValue }"
DataType: dataType, // string, xml, script, json, text
Async: asyncType, // synchronous asynchronous true/false
Error: function (XmlHttpRequest, xmlhttp, info ){
},
Success: function (result ){
// Callback function, result, Return Value
CallBack (result );
},
});}
Call: MyAjax ('post', "url? Id = "+ id, DoOK );
Note: async: true indicates asynchronous. This means that when ajax sends a request, the foreground will continue to execute the script after the ajax block while waiting for the server to return, success will not be executed until the server returns a positive result, which is equivalent to opening two threads; false is synchronization, that is, the foreground will wait for the server to return data before execution.