jQuery的load()方法及其回调函数用法实例
本文实例讲述了jQuery的load()方法及其回调函数用法。分享给大家供大家参考。具体如下:
下面的js代码演示了jQuery的load()方法的使用,并演示了带回调函数(callback)的load方法的使用
<!DOCTYPEhtml>
<html>
<head>
<scriptsrc="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){
if(statusTxt=="success")
alert("Externalcontentloadedsuccessfully!");
if(statusTxt=="error")
alert("Error:"+xhr.status+":"+xhr.statusText);
});
});
});
</script>
</head>
<body>
<divid="div1"><h2>LetjQueryAJAXChangeThisText</h2></div>
<button>GetExternalContent</button>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志