JSON super quick start 2 Basic Principles of AJAX technology

Source: Internet
Author: User

I have been wondering how my website can obtain remote JSON data and parse it.

Google has a lot on the internet, how to obtain remote data through AJAX, and finally found a sentence in w3cschool.

The first key:

With AJAX, your JavaScript can communicate directly with the server, using the JavaScriptXMLHttpRequestObject. With this object, your JavaScript can trade data with a web server, without reloading the page.

It turns out that XMLHttpRequest is used to send a request.

 

The second sentence is critical:

The XMLHttpRequest object is supported in Internet Explorer 5.0 +, Safari 1.2, Mozilla 1.0/Firefox, Opera 8 +, and Netscape 7.

This request supports most browsers.

The third key is how to create this Request:

<Script type = "text/javascript">
Function ajaxFunction ()
{
Var xmlHttp;
Try
{
// Firefox, Opera 8.0 +, Safari
XmlHttp = new XMLHttpRequest ();
}
Catch (e)
{
// Internet Explorer
Try
{
XmlHttp = new ActiveXObject ("Msxml2.XMLHTTP ");
}
Catch (e)
{
Try
{
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Catch (e)
{
Alert ("Your browser does not support AJAX! ");
Return false;
}
}
}
}
</Script>

 

Well. With the above basic knowledge, you will know how to play with AJAX. You will know how to obtain JSON.

 

Reference:

Http://www.w3schools.com/Ajax/default.asp

 

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.