Re: Saving AJAX responseText to a variable



<tempacct@xxxxxxxxxx> wrote:

ajaxObject.onreadystatechange = ajaxObjectStateChange;

This should be:
ajaxObject.onreadystatechange = ajaxObjectStateChange();

function ajaxObjectStateChange()
{
if(ajaxObject.readyState == 4)
{
my_variable = ajaxObject.responseText;
}
}

If readyState != 4 my_variable is not set.

As you can see, I use an alert to return the value I'm trying to
retrieve, but it always come up as undefined (or a empty string if I
initialize the variable).

Mainly because you were not calling the function.


.



Relevant Pages

  • Re: Order in metaclass
    ... The relevant part of the code is as follows (debug code removed): ... john.name will retrieve this value. ... name, it will automatically initialize the __attr__ dictionary, and ... properly use metaclasses, descriptors, properties, a lot of stuff. ...
    (comp.lang.python)
  • Re: ct_get_data() fails
    ... calling ct_get_dataon column 2 ... Only those columns following the last bound column are available to ... but can use ct_get_data to retrieve the data ... Replication Server raising the error. ...
    (comp.databases.sybase)
  • Re: Map.get(key) returns null after inserting key
    ... I am inserting a key and a object into a Map. ... to retrieve the object by calling ...
    (comp.lang.java.programmer)
  • RE: Closing user form in Initialize macro?
    ... Check for a valid connection (abiolity to retrieve) prior to initailizing the ... If you are not going to be able to run the retrieve then dont run the ... > I have a situation where the user form Initialize routine can fail to ... > display a msgbox, but I then have to display the form, which of course is ...
    (microsoft.public.excel.programming)
  • Re: ENOBUFS
    ... > end gave-up and closed the connection before the server could get ... > around to calling acceptto retrieve it. ... Only in a very very rare ...
    (comp.sys.hp.hpux)