Some understanding of XHR and Ajax

Source: Internet
Author: User

My understanding of Ajax. Ajax just encapsulates the XMLHttpRequest to re-open a thread. A response to the return value is made. And if we don't use xhr async, but only with synchronization, we can't make the next request until the request is complete. And on the landing, the partial refresh of this point of view, I can not understand. The use of XHR still enables partial refreshes, except that the other cannot be processed asynchronously. If we don't deal with XHR, then the browser defaults to just reloading a page. I guess. As a result, the original page is flushed out. If we use AJAX encapsulation, we'll deal with it. Instead of using the browser's default processing mode.

So Ajax is just an asynchronous request operation. Did not reach the result of a partial refresh. The result of an asynchronous flush is that we do not handle the return value of the browser. The browser defaults to the value we return and get the sub-page processing. If, as we have done with the value returned by the browser, it will not be a sub-page. But in this case, it really played a part of the role of refreshing AH. Because some of us are unable to deal with the result of the request.

to verify what I said, I'll use the button . to submit the page and use XHR to deal with the results, to see if he can refresh locally. If it can be partially refreshed, it satisfies the conjecture I have put forward.

It looks like the picture is not a XHR request, so there is no cross-domain impact.

Cross-domain impact satisfies several conditions

The JSON object is actually a JS object. The JSON text is transmitted.

XHR is the product of local refresh. Ajax is the product of asynchronous implementations.

As for the IFRAME, I guess it just intercepts the response, then processes the intermediate process so that it doesn't respond to the sub-page. Good. So the IFRAME is another page.

Async = False

To use Async=false, change the third parameter in the open () method to False:

Xmlhttp.open (" Get","test1.txt",false);

We do not recommend the use of Async=false, but for some small requests it is also possible.

Keep in mind that JavaScript waits until the server responds in readiness to continue. If the server is busy or slow, the application hangs or stops. Or we can not operate the other can only wait for this request to complete to operate the other. That's good fun. Is it? Is that the case? Fun.

I forgot about what I was going to say. Good helpless. Oh

In fact, the browser parsing the HTML words, line by row to parse. If you encounter js,css link, the browser will load asynchronously. Then the parsing.

Some understanding of XHR and Ajax

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.