avylon Posted August 6, 2007 Share Posted August 6, 2007 The very first sample in the W3School AJAX tutorial at http://www.w3schools.com/ajax/default.asp is not working for me. In this simple example, the time from the server is supposed to appear in the second textbox as I begin to type in the first textbox. Nothing happens at all, though. There are two pages in this example: ajaxTest.htm and time.asp. Both are hosted in the same folder. Here is the unaltered code for ajaxTest.htm: <html> <body> <script type="text/javascript"> function ajaxFunction() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer 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.myForm.time.value=xmlHttp.responseText; } } xmlHttp.open("GET","time.asp",true); xmlHttp.send(null); } </script> <form name="myForm"> Name: <input type="text" onkeyup="ajaxFunction();" name="username" /> Time: <input type="text" name="time" /> </form> </body> </html> ============================= Here is the code for time.asp: <% response.expires=-1 response.write(time) %> ============================= If I visit time.asp directly, I get the correct time. If I visit ajaxTest.htm and begin to type in the name field, nothing happens. I tried it in FF and IE. I'm on Windows 2005 Server, so ASP is not an issue, either. Do I need to make an IIS change for this to work? Thanks for any help. Patrick Link to comment https://forums.phpfreaks.com/topic/63583-most-basic-w3school-ajax-tutorial-not-working-for-me/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.