Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 3
Name: Ben
Trades: 0
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
 
 
Register now for full access!
Old 10-23-2007, 03:19 PM Re: AJAX Question...
Experienced Talker

Posts: 45
Trades: 0
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 =
__________________
-sites/domains i have-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
-
accesstimes is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX Question...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.19992 seconds with 12 queries