Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax request => How to read response?

    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:

    Code:
    	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!

  • #2
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The returned text is stored in 'ajaxRequest.responseText'

    Assuming your AJAX variable is called "ajaxRequest", you'd do something like:
    Code:
    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
    ====================
    Jon
    ====================


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •