my.js创建.js文件
var user={
add:function(){},
del:function(){},
update:function(){},
select:function(){
$.ajax({
data:{},
dataType:"json",
type:"get",
url:"showuser",
success:function(data)
{
alert(data);
var info="<table border=1>";
for(var i=0;i<data.data.length;i++)
{
info=info+"<tr><td>"+data.data[i].name+"</td></tr>";
}
info=info+"</table>";
$("#info").html(info);
}
});
}
}
var depe={
add:function(){},
del:function(){},
update:function(){}
}
前端进行引用.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="info"></div>
</body>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="my.js"></script>
<script type="text/javascript">
user.select();
</script>
</html>