Talking about the new page without refreshing ajax technology, talking about page refreshing ajax

Source: Internet
Author: User

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.

 

Related Article

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.