Blackberry WebWorks AJAX Problems
I recently spent some time debugging AJAX connections for a application I built for a client using Blackberry WebWorks (via PhoneGap) and jQuery Mobile. The app was already working great on iOS and Android, however my AJAX (XMLHTTPRequest's) were not working on Blackberry.
I quickly found that the
config.xml descriptor required whitelisting of the domain(s) you are connecting to. This particular app would be connecting to a number of unknown domains, so I had to use a wildcard like this:
<access uri="*" />
But I was still having a problem accessing my services, it would always report a 500 status code Internal Server Error.
Searching around for this issue I found some references to a Phonegap workaround for AJAX:
navigator.network.XHR - this however is not part of phonegap for WebWorks, it is part of the older phonegap which used the Blackberry java SDK rather than WebWorks. Unless you need to support old Blackberry phones (which uses a really barebones browser, not webkit) you probably want to be using the WebWorks version of PhoneGap.
It turns out my problem was very simple. Every time the simulator was fired up Networking was turned off, so you have to explicitly turn on the Wifi each time!
Here are a few tips on working with Blackberry WebWorks and PhoneGap:
- When working with PhoneGap make sure you are using the blackberry version of
phonegap.jsand also make sure that you have included
json2.js(required in v0.9.4)
- If you run into JVM Error 545, run the clean.bat located in the simulator directory.
- Add this JS to make the page take up the full screen height:
document.body.style.height = screen.height;
- Keep in mind that if you want to support Blackberry 5, it's browser is not nearly as good as Blackberry 6, HTML5 features like
localStoragemay not work.
- Checkout the Blackberry WebWorks Forum's Tips, Quirks & Solutions Thread
Like this? Follow me ↯Tweet Follow @pfreitag
Blackberry WebWorks AJAX Problems was first published on May 09, 2011.
If you like reading about blackberry, mobile, webworks, troubleshooting, ajax, phonegap, or jquerymobile then you might also like:
- Building iPhone Android Apps with jQuery Mobile and PhoneGap Slides
- Building a Web Browser App for Blackberry Playbook Simulator
- Getting Started with Blackberry Playbook App Development
- Getting Started with jQuery Mobile