<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ajax.html</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="ajax.js" charset="utf-8"></script>
<script type="text/javascript">
function say(obj) {
alert(obj['a']);
}
window.onload = function() {
var getDate = document.getElementById('getDate');
getDate.onclick = function(){
/*var jsonpScript = document.createElement('script');
jsonpScript.type = 'text/javascript';
jsonpScript.src = 'http://127.0.0.1:8080/Ajax/get.jsp';
document.getElementsByTagName("head")[0].appendChild(jsonpScript);
document.getElementsByTagName("head")[0].removeChild(jsonpScript);*/
SX.Ajax({
url : 'get.jsp',
type : 'GET',
dataType : 'json',
timeout : 2000,
data : {name : 'sx', password : '456'},
success : function(data) {
alert(data['b']);
},
complete : function(xml, status) {
alert('返回错误,错误代码:' + status);
},
error : function() {
alert('出错了');
}
});
}
}
</script>
</head>
<body>
<button id="getDate">查询</button>
</body>
</html>
get.html
最新推荐文章于 2024-07-17 18:42:40 发布