Ajax HTTP Request mode

Source: Internet
Author: User
Tags http request

1. Setting Up Xmlhttprequest/msxml2.xmlhttp objects

This should be the most common way, very easy to use, can really connect XML objects,

Can be submitted by "POST" "GET",

However, cross-domain is not supported in Firefox

2. Use DOMDocument object, but IE and Firefox are very poor,

The request can be made through the object's load (URL), which is, of course, only a Get mode,

The returned result can only be XML, with the same onreadystatechange processing callback,

Cross-domain is not supported in Firefox

3. Use the IFRAME to make a request, set the SRC attribute, make a GET request,

The. Document.body of the pass-through object takes the return value, the. OnLoad processing callback,

However, the cross-domain is not supported in Firefox and Iframe.document is inaccessible in Firefox.

4. Dynamically create <script> tag, set src attribute, issue get request,

The benefit of this request is that it executes the returned result as a script, and supports cross-domain in Firefox.

Processing the callback as long as the result of the request service is a script,

If the return result is response (0,{},0), the response (0,{},0) is called when the request ends

Where the parameter can return an object in this manner {a:1,b:function () {}}.

But dealing with XML can be a bit cumbersome.

5. Use the script (new Image ()). src = "url"; This also makes it possible to make a GET request, but cannot process the return value.

Can be used when you don't need to process the return results.

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.