JQuery Ajax Getscript Examples and detailed tutorials

Source: Internet
Author: User

Jquery.getscript (URL, [Success (data, Textstatus)]) returns:xmlhttprequest

Jquery.getscript (web site, [Success (information, textstatus)])
Urla string that contains the URL of the request being sent.

Successful (data, textstatus) callback functions if the request is successfully executed.

This is an abbreviated AJAX feature, which is equivalent to:

$.ajax ({
Url:url,
DataType: ' Script ',
Success:success
});
Callback is the Web page effect file returned by. This is usually not the use of the script that will have been run at this point.

The script is executed globally, so it can refer to other variables and use the jquery function. Include the script should have some effect on the current page:

$ ('. Result '). HTML (' <p>lorem IPs tutorial um dolor sit amet.</p> '); The script can then is included and run by Referenci ng the file name:

$.getscript (' Www.111cn.net/test.js ', function () {
Alert (' Load was performed. ');
});

Example:
For example: Load the official jquery plugin dynamic color animation and bind some color animations to appear once new features are loaded.

<!doctype html>
<style>.block {
Background-color:blue;
width:150px;
height:70px;
margin:10px;
}</style>
<script src= "Http://code.jquery.com/jquery-latest.min.js" ></script>
<body>
<button id= "Go" >&raquo; Run</button>

<div class= "Block" ></div>

<script>$.getscript ("Http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function () {
$ ("#go"). Click (function () {
$ (". Block"). Animate ({backgroundcolor: ' Pink '}, 1000)
. Animate ({backgroundcolor: ' Blue '}, 1000);
});
});</script>

</body>

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.