<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
</head>
<body>
<div class="ee">
<button>test1Html</button><button>test2Html</button>
</div>
<div id="mainBox">
00000
</div>
</body>
<script type="text/javascript">
var yt = $.extend({
loadDom: function () {
var arglen = arguments.length;
id = "mainBox", fc = null;
if (arglen < 1) {
yt.msg("没有传递需要加载的URL参数!", "e");
return false;
}
if (arglen == 2) {
fc = arguments[1];
}
if (arglen == 3) {
id = arguments[2];
}
$.ajax({
url: arguments[0] + ".html",
cache: false,
async: false,
timeout: 3000,
success: function (data) {
alert(data);
$id.html(data);
if (typeof fc == "function")
fc();
},
error: function () {
yt.sendmsg("networkerror");
}
});},
loadTest1 : function() {
yt.loadDom("test1", function() {
});
},loadTest2 : function() {
yt.loadDom("test2", function() {
});
}
var $id= $("#mainBox")
$(function(){
$(".ee button").click(function(){
var $html=$(this).text()
switch ($html){
case "1":yt.loadTest1();break;
case "2":yt.loadTest2();break;
case "3":yt.loadTest3();break;
}
})
})
</script>
</html>