Reply
AJAX Question...
Old 10-20-2007, 05:23 AM AJAX Question...
Junior Talker

Posts: 3
Name: Ben
Hey!

So, I decided to get off my butt and play with AJAX. I was pleasantly surprised, it really didn't look that hard, so I went ahead and began to play with a VERY simple function:

Code:
<script language="javascript" type="text/javascript">

request = new XMLHttpRequest();  
  
function grabEcho() {
  
  var url = "./echo.php";
 
     request.open("GET", url, true);
     
     request.onreadystatechange = updatePage;
     
     request.send(null);
     
}

function updatePage() {
      
    if (request.readyState == 4)
     
        document.getElementById("test").value == xmlHttp.responseText;
         
   }
</script>

<form action="POST">

<input type="text" name="test" id="test" onChange="grabEcho();"><br />

<input type="text" name="another" id="another">

</form>
Trouble is... It didn't work!

I know that way of declaring XMLHttpRequest() won't work for all browsers, I'm using Firefox at the moment, just to play, and from what I've read it should work.

echo.php just echoes 'lol', so theoretically, when I go to enter something in the test field, and click off it, it's contents should be replaced with 'lol'. Unfortunately, this isn't happening. What have I screwed up?

Thanks in advance!
benzoenator is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 10-23-2007, 02:19 PM Re: AJAX Question...
Experienced Talker

Posts: 45
I found several problems with it. It first
showed xmlHttp was not valid, though request is.

looks like you wern't checking the javascript console that firefox has.

second I don't think this works for form inputs :
document.getElementById("test").value =
accesstimes is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX Question...
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11728 seconds with 12 queries