Ajax technology to achieve no refresh page

Time:2020-9-13

Ajax (ajax development)

Ajax, namely “asynchronous JavaScript and XML” (asynchronous JavaScript and XML), is a web development technology to create interactive web applications.

Ajax = asynchronous JavaScript and XML (a subset of the standard common markup language).

AJAX is a technology for creating fast dynamic web pages.

Through a small amount of data exchange with the server in the background, AJAX can make web pages update asynchronously. This means that you can update a part of a web page without reloading the entire page.

Traditional web pages (which do not use ajax) have to reload the entire web page if they need to update the content.

Now the general website is to use ajax to achieve page no refresh operation.

What is no refresh: Ajax can realize the data interaction between the page and the background, and the user can not feel that the page has any refresh, which is Ajax no refresh.

Ajax method implementation:

You can encapsulate Ajax to facilitate the calling of various pages

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, // url, it is better to add a URL+ Math.random (), which ensures that the requested page is treated differently 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);

Description: async: true means asynchronous. This method means that when Ajax sends a request and waits for the server to return, the foreground will continue to execute the script behind the Ajax block until the server returns the correct result, which is equivalent to opening two threads; false is synchronization, that is, the foreground will wait for the server to return data before executing.

About Ajax technology to achieve page no refresh effect, small editor to introduce so much, I hope to help you!