ASP. NET + jquery. Ajax details 5-$. getscript

Source: Internet
Author: User

 

Directory (updated articles will be connected, and an article will be updated every two to three days starting from March 13, July 25 ):

ASP. NET + jquery. Ajax details 1-opening section (published on February 25)

ASP. NET + jquery. Ajax details 2-$. Load (published on 2012.07.26)

ASP. NET + jquery. Ajax details 3-$. Get and $. Post (published on February 30)

ASP. NET + jquery. Ajax details 4-$. getjson (published on February 31)

ASP. NET + jquery. Ajax details 5-$. getscript (2012.08.04)

ASP. NET + jquery. Ajax details 6-$. ajaxsetup (2012.08.06)

ASP. NET + jquery. Ajax details 7-Global Ajax events (published on 2012.08.09)

ASP. NET + jquery. Ajax details 8-core $. Ajax (published on February 12)

ASP. NET + jquery. Ajax details 9-serialize and serializearray (February 15)

ASP. NET + jquery. Ajax detailed description: 10-json and XML + are written at the end of the article (published on February 20 !)

 

 

Jquery. getscript (URL, [callback])

Load and execute a Javascript file through an http get request.

 

URL: the URL of the JS file to be loaded.

Callback: callback function after successful loading.

The jquery internal implementation of this function still uses the get function. getscript imports the type parameter with the value of "script". Finally, the Ajax function processes the request with the type as script as follows:

 

var head = document.getElementsByTagName("head")[0];            var script = document.createElement("script");script.src = s.url;

 

The above JS Code creates a script statement block and adds it to the head:

Head. appendchild (SCRIPT );

After the script is loaded, the JS Code deleted from the header will be omitted. If you are interested, study jquery.

I only did a non-Cross-origin test, and I will have time to complete another cross-origin test.

 

Instance:

Client --

<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "jqueryajaxgetscript. aspx. cs" inherits = "jqueryajaxtest. jqueryajaxgetscript" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

The javascript code in test. js requested by the client is as follows:

Alert ("the Javascript file test. js of the getscript request has been loaded! ");

 

The test code is simple and the results are clear at a glance.

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.