views:

1029

answers:

2

I am experimenting with the new Safari 5 extensions JS API and I am having an issue right from the ground up, I want to use an XMLHttpRequest to get an RSS feed from a website however upon the .send() it immediatly kicks off errors:

Failed to load resource: cancelled

Then looking at the XMLHttpRequest object is says in status: Error: INVALID_STATE_ERR: DOM Exception 11

I don't know why but this is my code, I hope I can get some advice as to whats going wrong:

var xml = new XMLHttpRequest();
xml.open('GET', 'http://year3.gdnm.org/feed/');
xml.send();

Thanks in advance.

+1  A: 

There may be an error in XML of page "http://year3.gdnm.org/feed/" and Safari couldn't parse this document, hence the error.

mav
I don't think so because this code works fine when not part of a Safari extension and the RSS is generated by WordPress, which although not unfalable this issue has not been noted before in any XML requests before.
unknowndomain
+2  A: 

Make sure that in Extension Builder you have given your extension access to the site. Under the heading "Extension Website Access" set the access level to "all" or set it to "some" and provide "year3.gdnm.org" as an allowed domain pattern.

Scott Thompson
I did check that but it makes no difference and according to the Apple documentation this is only a control over injecting content into the page:http://developer.apple.com/safari/library/documentation/Tools/Conceptual/SafariExtensionGuide/ExtensionPermissions/ExtensionPermissions.html
unknowndomain
I don't know what to tell you about the documentation, I can tell you that I had the exact same problem and adding the domain to the patterns list solved the issue for my XMLHTTPRequests. Just to make sure, before posting this I ran an experiment where I removed the domain I was trying to reach from XMLHTTPRequest from my allowed domains and I verified that I could no longer make the requests.
Scott Thompson
Seems to be working now, thanks for that, I didn't get back but did try it out and it worked after. Thanks!
unknowndomain