Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
araskin
Posts: 128
Registered: ‎08-01-2008
My Device: Bold 9900, 9810, 9780, 9650 and so many others

XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Platform: BlackBerry 10 WebWorks

Ripple: 0.9.10

Chrome: 23.0.1271.64

 

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:

 

.....

    <authorId>**</authorId>
    <name>Toolkit Test</name>
    <content src="index.html"/>
    <access uri="http://localhost:9910/ToolkitTest/http_handler" subdomains="true">
        <feature id="blackberry.identity" required="true"/>
    </access>
</widget>

 

Any ideas what am I doing wrong? Is it possible to XHR to a local file (which is delivered as part of the app)?

 

Regards,

 

Alon

Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Try adding 

 

<access uri ="*"/>

 Into your config.xml



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
Developer
araskin
Posts: 128
Registered: ‎08-01-2008
My Device: Bold 9900, 9810, 9780, 9650 and so many others

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Thanks. Just tried it. Still no joy.
Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Perhaps <feature id="blackberry.io.file" required="true" version="1.0.0.0"/> ?

 

https://developer.blackberry.com/html5/apis/blackberry.io.file.html it seems to be a necessary parameter for Ripple.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

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:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Basic-XMLHttpRequest-sample-requ...

 

Though in that sample we use this path:

"http://labs.adobe.com/technologies/spry/data/photos.csv"

 

If I wanted to access a local file packaged with my app, I would simply do a relative reference:

"./resources/myfile.csv"

 

In that case, because I'm not going cross-domain, no white-listing should be necessary.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
The_Anomaly
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

It's a security "feature" in chrome.

 

You need to create a shortcut to run chrome and add:

chrome.exe --disable-web-security

 

to the end of your target.

 

If it helped you, click like. :smileyhappy:
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

 

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

 

header("Content-Type: text/xml");
header('Access-Control-Allow-Origin: *');
header_remove("X-Powered-By");
header_remove("Set-Cookie");

echo $xml;

 

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'




Click the like button if you find my posts useful!
Please use plain text.
Developer
araskin
Posts: 128
Registered: ‎08-01-2008
My Device: Bold 9900, 9810, 9780, 9650 and so many others

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Hi Everyone,


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:

 

POST http://localhost:9910/ToolkitTest/http_handler/contacts.xml 404 (Not Found)

 

Feels like we are getting close but I still cant make a successful call to contacts.xml

 

Any further throughts anyone?


Alon

Please use plain text.
Developer
araskin
Posts: 128
Registered: ‎08-01-2008
My Device: Bold 9900, 9810, 9780, 9650 and so many others

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Erik,

The file is packaged as part of the application. I tried accessing without specifying the protocol but I am getting a message saying that the file could not be found (404 error). The contacts.xml file is in the same directory as all the JS and HTML files.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: XHR fails with NETWORK_ERR: XMLHttpRequest Exception 101 in Ripple

Just to confirm, can you please provide the full path (on your PC) to:
1) config.xml
2) The JS or HTML file that is trying to read contacts.xml.
3) contacts.xml

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.