这是我的页面Test1.asp
<html> <head> <Meta http-equiv="Content-Language" content="en-us"> <Meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> <script type="text/javascript"> function Alex() { var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById("Alex").innerHTML =xmlHttp.responseText;//Get Google Destination Map } } xmlHttp.open("GET","Test2.asp",true); xmlHttp.send(null); } </script> </head> <body> <div id ="Alex"></div> <label onclick="Alex()" >ssss</label> </body> </html>
这是请求页面Test2.asp
<html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head> <body> <div id="Mathew"></div> </body> <script type="text/javascript" > { document.getElementById("Mathew").innerHTML='ajax is working'; } </script> </html>
在页面(Test2.asp)中javascript无法正常工作
如何使用ajax将test2.asp调用到我的test1.asp
默认情况下,不会执行包含AJAX响应的JavaScript.
原文链接:https://www.f2er.com/ajax/160183.html当这个问题已经在各种库中解决时,就像jQuery和Prototype一样,从头开始构建Ajax处理程序毫无意义.