Jump to content

AJAX help!


Recommended Posts

I copied it right from the AJAX page, and it just doesn't work... :) what am I doing wrong?http://clone-drone.net/axaj_test.html

<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","http://clone-drone.net/time.php",true);//my host doesn't support ASP... so I used PHP  xmlHttp.send(null);  }</script><form name="myForm">Name: <input type="text"onkeyup="ajaxFunction();" name="username" />Time: <input type="text" name="time" /></form></body></html>


<?phpecho "testing";return "123";?>

ASP doesn't work with my host... so I used PHP... what am I doing wrong?

Link to comment
Share on other sites

It's working OK in my browsers.Your "return 123;" line isn't necessary. AJAX receives any text that you would see by opening the PHP file directly.Just use echo to display the information you want.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...