--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
This looks wrong... is it a typo, or is that what you actually have in
your code? Seems like it should be req.onLoad = handleResponse;
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
req.onError = function () { alert("Error on XMLHttpRequest!") }
Similarly, handleResponse is being called every time because you are
calling it every time. It should be referenced without the parentheses:
req.onLoad = handleResponse;
I don't know if that will fix all of your problems, though.
Oh, and you dropped the list from CC; be sure to hit reply-all if you
mean to send the message to the list. ;-)
> The following code works but the last line always triggers the onError
> alert. If I use this code in the default popup from a browser action,
> run it under "inspect popup" monitoring req.status and req.readystate,
> these values go to 200 and 4 right away if running synchronously but
> never get past 1 if running asynchronously.
>
> handleResponse is a function and when the code executes as below,
> handleResponse gets called.
>
> req = new XMLHttpRequest();
> if (req == null){
> alert("Unable to create request");
> };
> req.open("GET", feedUrl, false);
> req.send();
> req.onLoad = handleResponse();
> req.onError = alert("Error on XMLHttpRequest!");
>
>
> On Tue, Jun 14, 2011 at 6:04 PM, Ben <benj...@gmail.com> wrote:
> On Tue, 2011-06-14 at 03:42 -0700, jeromekjerome wrote:
> > req.onLoad = handleResponse();
> >
> > If to code this as an asynchonous get, how do I know when it
> finishes
> > loading? onLoad just returns that same values forever as
> far as I can
> > see. Do I need a listener or do I need to fire some other
> event so
> > that onLoad updates its status? I think I remember a C++
> example,
> > where it was necessary to put it into a loop with a
> "message-aware
> > delay" until the request came back ready.
>
>