On Wed, May 13, 2009 at 10:06 PM, filthysock <[email protected]> wrote:
>
> Hi everyone,
> I just converted a greasemonkey script into an extension. Yeah, it
> doesn't do any extensiony stuff yet, but maybe in the future.
>
> I'm trying to do a Cross-Origin XHR request, but i'm having a problem
> with responses.
> It sends the request ok (data gets updated on the other server) but i
> only ever get a status code 0 and no status text at all in response,
> is there's something i'm missing?
>
> Grab the crx here
> http://www.filthysock.com/chromelol.htm
> -------------
> Sample Code
> var request = new XMLHttpRequest();
>
>  request.onreadystatechange = function() {
>
>    if (result.readyState == 4) {
>      // request is complete, but result.status always equals 0
>    }
>  }
>
> request.open("GET", addr, true);
>
> request.setRequestHeader("Accept", "application/xml,application/xhtml
> +xml,text/html,text/plain");
>
> request.send(null);

You're not currently allowed to do cross-origin XHR from content
scripts, only from the main extension process. You need to send a
message to the extension and have it do the request for you.

There's some detail on the messaging API here:
http://dev.chromium.org/developers/design-documents/extensions/content-scripts

- a

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected] 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to