JavaScript returned by AJAX is not working. How to work with JavaScript? -
this page 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 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>
this requested page 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 working'; } </script> </html>
in page (test2.asp) javascript not working
how call test2.asp test1.asp using ajax
by default javascript contained ajax responses not executed.
there no point in building ajax handler scratch when problem has solved in various libraries jquery , prototype.
Comments
Post a Comment