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

Android™ Development

Reply
New Contributor
Posts: 3
Registered: ‎05-05-2013
My Device: Z10
My Carrier: NA

Exception 101 When Making GET Request for Local Javascript File

Hello,

 

I am porting an Anroid APK to BB10.  The porting process is painless and works wonderfully!  But we have a major issue that makes our entire application non-functional.  Need some help here.  Here is some background:

 

Our app uses PhoneGap to create the Android APK.  Furthermore, we use a javascript library called Stratified JavaScripte (Apollo.js from ONILabs) so that we can transform loads of async javascript code into non-blocking synchronous javascript.  (This is hugely helpful and I highly recommend checking this out.)  The Apollo script uses a "require" statement to load my javascript file and work its magic.  The "require" function does an HTTP GET request to obtain the javascript file.  Beause this is a PhoneGap app, all code is local to the app.  The first page to load is index.html and then I need to "require" a javascript file that is sitting right next to index.html, or in a Scripts directory.

 

The problem is that in this context I cannot make an HTTP GET request to my javascript (*.js) file.  When I try, I get the following exception:

 

NETWORK_ERR: NETWORK_ERR: XMLHttpRequest Exception 101

 

I thought maybe it was restricting it by file extension, but that is not the case.  I made a test.txt file with just the word "test" in it, and that also gives the same error.

 

HOWEVER...  If I request index.html, it works and I get the HTML source of the file.  So this leads me to believe that my HTTP GET code is correct, but there is some security (CORS?) layer that is disallowing the request.

 

I found the following forum post:

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Ajax-JSON-crossDomain-CORS-Optio...

 

In which is looks like the OP has the same issue.  The suggestion is made to use config.xml to add these settings:

 

<access subdomains="true" uri="*"/>

 

<feature id="blackberry.app" required="true" version="1.0.0.0">
    <param name="websecurity" value="disable" />
</feature>

 

But I don't believe that I have access to a config.xml that the OS/browser/Android Runtime will make use of.  Or do I?  I have a config.xml file that is used by PhoneGapBuild to create my Android APK file.  It is used to instruct PhoneGapBuild about various things such as icons, splash screens, and other preferences.  Just as a shot in the dark, however, my next test will be to add these settings to that file and see if somehow they persist through the build process and if by some stretch of the imagination BB10 is able to make use of them in that file.

 

If anyone has any thoughts for me, I really look forward to reading them.  Thank you very much in advance!

 

AN

New Contributor
Posts: 3
Registered: ‎05-05-2013
My Device: Z10
My Carrier: NA

Re: Exception 101 When Making GET Request for Local Javascript File

Update...  I tried adding those lines to my config.xml but it did not change anything - same test results as previous.