I'm having the following problem.
I'm developing an app with Phonegap
, and I have some trouble with the AJAX
call on Blackberry. When I call the ajax service with datatype = 'xml'
, it works fine on Windows Phone, and Android but failed on Blackberry.
This is the code:
jQuery.ajax({
url: requestedUrl,
dataType: 'xml',
timeout: this.timeout,
beforeSend: _.bind(this.beforeSendCallback, this),
success: _.bind(this.internalSuccessCallback, this),
error: _.bind(this.internalErrorCallback, this),
headers: {'X-Requested-With': 'XMLHttpRequest'}
})
I read on others post, that you cannot do anXMLHttpRequest
to an external domain, which is the error that Blackberry shows (but I don't understand why it works on the other two platforms.) So I try to change the dataType to 'jsonp', but a syntaxError shows up. I tried with jsonp text xml
, but for some reason it does not and returns the same
Uncaught SyntaxError: Unexpected token <
Looking, the response of the WS, it gave me back a valid XML
. So the question is, How can I use that XML if I'm making the call with jsonp
?
EDIT:
Actually, the problem was that the "origin" header was "local:\" (my app), so BB was blocking the content of the response. The solution was to add that domain to my config.xml
, like this:
<access uri="local:///" subdomains="true" />
Unlikely Android and Windows Phone, in the config.xml
you have to set access to the domains with uri, not origin and the * wildcard is not allowed with XmlHttpRequest (XHR) on BlackBerry 10.