To create a XMLHttpRequest object write a standard function

Source: Internet
Author: User
Tags event listener

function Loadxmldoc (url,callbackfunc)
{
if (window. XMLHttpRequest)
{//ie7+, Firefox, Chrome, Opera, Safari code
Xmlhttp=new XMLHttpRequest ();
}
Else
{//IE6, IE5 code
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
Xmlhttp.onreadystatechange=callbackfunc;
Xmlhttp.open ("GET", url,true);
Xmlhttp.send ();
}

------------------------------------Split Line---------------------------------------------------------------------------------- ------

A personal understanding of the callback function:

The callback function, which is literally understood, even calls this function back. By using a function pointer as a parameter to a function, this pointer acts as an interface.

If the callback function is bound to the onReadyStateChange event----Here This callback function is equivalent to an event listener and an operation interface, and when we need to do something about a value of an event, we define the corresponding callback function.

Back to the abstract, if the function A's callback function pointer is b), a in the completion of the function declaration, the definition of its execution code (that is, function A is a fixed method), B as a parameter, B can be defined outside the function, as a parameter passed into the inside of function A, Additional operations are performed by some of the variable values derived from function A.

Think of two comparison image of the metaphor, but also through other blog ideas evolved, 1 function A is equivalent to a ceramic factory, callback function B is a mold factory, porcelain factory dug to the mold factory processing, mold factory processed and then sent to the porcelain factory processing refined into finished porcelain, this is called customizable.

One more thing, like I have a circuit system a, when the system load to a certain threshold, it is necessary to pass through the circuit system of the reserved interface to a variety of measuring instrument detection circuit security.

Beginner Javasript, some humble opinion, understand the wrong place hope to get all the way big God big fairy or monsters (¬_¬)! Please advise to correct!

To create a XMLHttpRequest object write a standard function

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.