11-20-2012 12:08 PM
Platform: BlackBerry 10 WebWorks
I have created a webApp and am testing it inside Ripple for WebWorks BB10. After the load of the page, the page tries to do an XHR on a local page (contacts.xml) which is packaged as part of the app. However this fails every time. The alert popup that I get in chrome is
NETWORK_ERR: XMLHttpRequest Exception 101
When I look inside the Chrome Console I see the following:
XMLHttpRequest cannot load local:///contacts.xml. Cross origin requests are only supported for HTTP.
I guess I am going about this the wrong way but not sure what I am doing wrong. in my config.xml I have the following:
<feature id="blackberry.identity" required="true"/>
Any ideas what am I doing wrong? Is it possible to XHR to a local file (which is delivered as part of the app)?
11-20-2012 05:08 PM
<access uri ="*"/>
Into your config.xml
11-21-2012 11:58 AM
Perhaps <feature id="blackberry.io.file" required="true" version="22.214.171.124"/> ?
11-22-2012 12:09 PM
When you say local file, do you just mean a file that has been packaged into the WebWorks appliation directly? If so, have you tried the request without any protocol?
There is a basic XMLHttpRequest sample here:
Though in that sample we use this path:
If I wanted to access a local file packaged with my app, I would simply do a relative reference:
In that case, because I'm not going cross-domain, no white-listing should be necessary.
11-23-2012 07:55 AM
It's a security "feature" in chrome.
You need to create a shortcut to run chrome and add:
to the end of your target.
11-24-2012 06:30 PM
Thats a CORS issue
You can install a Web Server like XAMPP for local testing which will pass CORS
If you've on an eternal server I use the following before returning data (adapted from proven PHP)
// $xml has the XML you want returned to the client
As the previous post notes you can by-pass Chrome's very annoying safety mechanisms with the switch (I use this frequently when quick-testing)
You won't find the same problem with other browsers - I think only Chrome has the XDOM 'feature'
11-26-2012 09:00 AM
Thanks everyone for their reply. So based on your advice:
1. I added the arguements to the chrome.app and this did make the issue go away but I got an error saying that loca:///contacts.xml could not be found
2. So based on a previou advice I remove the "local:///" and make the URL just contacts.xml
Now I get the following in the console:
Feels like we are getting close but I still cant make a successful call to contacts.xml
Any further throughts anyone?
11-26-2012 09:02 AM
11-26-2012 11:19 AM