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" >» 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>