![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
为什么我把ajax的js改为外部调用就报错了呢
CODE: <html> <head> <title>AJAX测试</title> <script type="text/javascript" src="ajax.js"></script> </head> <body> <form action="#"> <input type="button" value="点击测试异步响应" onClick="starRequest();"> <!--在此报错,说缺少对象--> </form> </body> </html> |
ajax.js
CODE: <script type="text/javascript"> <!-- var xmlHttp; function createXMLHttpRequest(){ if (window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } } function starRequest(){ createXMLHttpRequest(); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.open("get","simpleResponse.xml",true); xmlHttp.send(null); } function handleStateChange(){ if(xmlHttp.readyState == 4){ if(xmlHttp.status == 200){ alert(xmlHttp.responseText); } } } --> </script> |
另外还有个问题,PHP怎么相应ajax(xmlhttprequest)呀,我在php里 echo不起做用呢
提问者:阿军 08-22 15:03
答复

