为什么ajax里的xmlHttp.responseText显示的全部是HTML
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content...
<html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="javascript"> var xmlHttp; function createXMLHttpRequest(){ if(window.ActiveXObject) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); else if(window.XMLHttpRequest) xmlHttp = new XMLHttpRequest(); } function startRequest(){ createXMLHttpRequest(); xmlHttp.open("GET","h.php",true); xmlHttp.onreadystatechange = function(){ //判断异步对象与服务器之间的交互状态 if(xmlHttp.readyState == 4 && (xmlHttp.status == 200)||(xmlHttp.status==0)) alert("服务器返回:" + xmlHttp.responseText); } xmlHttp.send(null); } </script> </head> <body> <input type="button" value="测试异步通讯" onClick="startRequest()" /> </body> </html> h.php <?php echo 1; exit(); ?> xmlHttp.responseText返回的是全部的php代码,不是1,为什么?
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询