zl程序教程

您现在的位置是:首页 >  前端

当前栏目

Jquery Ajax xml版Get请求PHP

jQueryPHPAJAXXML 请求 get
2023-09-11 14:17:23 时间

 


<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title></title>
<style>


</style>
</head>
<body>
<input type="button" value="AJAX提交"/>
<p id="resText"></p>
</body>
<script src="../js/jquery-1.11.3.js"></script>
<script>
$(function(){
$(":input").click(function(){
var xmlHttpReq=null;
if(window.ActiveXObject){
xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttpReq=new XMLHttpRequest();
}
xmlHttpReq.open("GET","text.php",true);
function RequestCallback(){
if(xmlHttpReq.readyState==4&&xmlHttpReq.status==200){
document.getElementById('resText').innerHTML=xmlHttpReq.responseText;
console.log(typeof xmlHttpReq.responseText);
}
}
xmlHttpReq.onreadystatechange=RequestCallback;
xmlHttpReq.send(null);
});

})
</script>
</html>