jQuery基础----22jQuery AJAX-加载片段

来源:互联网 发布:西城区2016年经济数据 编辑:程序博客网 时间:2024/06/07 08:11
box.htm:
<div style="width: 100px; height: 100px;background-color: coral"></div>
hellojs.js:
/** * Created by zsgjs038 on 2015/9/9. */function sayHello(){    alert("hello ajax");}
main.html:
<!DOCTYPE html><!--jQuery AJAX-加载片段--><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <script src="jquery-2.1.4.min.js"></script>    <script src="main.js"></script></head><body></body></html>
main.js:
/** * Created by zsgjs038 on 2015/9/9. */$(document).ready(function(){    $("body").text("wait...");    $("body").load("box.htm",function(a,status,c){        console.log(status);        if(status=="error"){            $("body").text("片段加载失败");        }    });//    加载对话框文件    $.getScript("hellojs.js").complete(function(){        sayHello();    });})
源码下载:
http://download.csdn.net/detail/zhaihaohao1/9093153

0 0
原创粉丝点击