...

Ajax request => How to read response?

arne2
12-19-2007, 04:13 PM
Hi, i'm sorry because it might be a stupid question but i'm new to ajax!
Ok, here's the problem: I have a working ajax script, and a part of the ajax code is this:


ajaxRequest.open("GET", "http://www.webmasterhelp.biz/pilotlight/vote.php" + queryString, true);
ajaxRequest.send(null);


The problem is that i don't know how to get the information the vote.php pages prints out in a variable that i can print on the current page
so basicly my question is: How to get the response of the ajaxrequest in a var that i can return?

I've searched a bit on google but th eproblem was they were all using a different ajaxrequest method and they all use xml and i don't think i need that, or do I?! Thanks for your help!

GeForce
12-24-2007, 02:28 AM
The returned text is stored in 'ajaxRequest.responseText'

Assuming your AJAX variable is called "ajaxRequest", you'd do something like:
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.writeln(ajaxRequest.responseText);
}
}
ajaxRequest.open("GET", "http://www.webmasterhelp.biz/pilotlight/vote.php" + queryString, true);
ajaxRequest.send(null);

Jon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum