06-14-2011 09:55 PM - edited 06-14-2011 10:00 PM
Hello everyone, this is my first post (desperate post!)
I have been working on this app for about a month, it uses the following scripts/frameworks/SDK:
- jquery 1.6.1
- jquery mobile 1.0a4.1
- BlackBerry WebWorks SDK2.0.0.201103231828-18
- BlackBerry WebWorks Plug-in2.5.1.201010291444-2 (eclipse)
it uses JSONP to avoid ajax cross-domain restrictions (app and data in different servers), and is working fine with chrome and BB browser (OS v6.0.0.576) on my phone, no restrictions at all. But when I compile and install the app as a native Webworks app on the phone, every request (same network, same external IP, etc.) I get nothing, status = 0 statusText = timeout on every request. My config.xml is this:
<?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0.1"> <name>My app</name> <author rim:copyright="xxx" email="xxx">xxx</author> <access subdomains="true" uri="*"/> <icon rim:hover="false" src="img/bricks.png"/> <icon rim:hover="true" src="img/brickshover.png"/> <content src="index.html"/> <rim:loadingScreen foregroundImage="img/splash.png" onFirstLaunch="true"> <rim:transitionEffect type="zoomIn"/> </rim:loadingScreen> <rim:cache disableAllCache="true"/> </widget>
just set domain access to "*", and even with that nothing happens ![]()
As in documentation, if remote domains/IPs change dynamically then is recommended using "*" to avoid restrictions, in this case it seems not to be working as expected.
This is how i´m making calls over JSONP:
(with jquery)
function queryService(srvUrl, callbackFunc){
if(globalVars['ssl'] == "1"){
srvUrl = "https://"+srvUrl;
}else{
srvUrl = "http://"+srvUrl;
}
$.mobile.pageLoading();
$.ajax({
type: "GET",
url: srvUrl,
crossDomain: true,
cache: false,
dataType: "jsonp",
jsonp : "callback", //Server only supports JSONP param name "callback"
jsonpCallback: callbackFunc,
timeout: 10000,
error: (function(xhr, ajaxOptions, thrownError){
$.mobile.pageLoading(true);
alert("Error:"+xhr.status+"-"+xhr.statusText+"-"+t hrownError);
}),
success: (function(){
$.mobile.pageLoading(true);
})
});
}Now just make every call like this:
queryService("192.168.1.12:8051/info/AABBCCDD", "mycallbackfunc");
Now the funny part is that the app is fully functional as a webpage on mobile (BB browser os6) and desktop, but as a native app for blackberry it doesn't retrieve information.
Even changed to another JSONP library (Lightweight JSONP fetcher by Erik Karlsson) just to discard a bug on jquery but got the same result.
Any suggestions? your help will be much appreciated, thanks!
EDIT: I forgot, on BB 9800 emulator (OS v6.0.0.227) it works just as expected (compiled app).
Solved! Go to Solution.
06-16-2011 10:56 AM
Ok, found it!
, domain access "*" only works for public IPs, so no intranet love for my app, but that's ok