I'm developing a mobile app and try to do most parts in HTML/CSS/JS embedded in a WebView. The app needs to get data from a XML-webservice while the HTML/CSS/JS-code is supposed to be on the local filesystem. However that gets me into the "same-origin-policy"-issue for Ajax-calls, because WebKit sets the Origin to null for local files. However I noticed that when setting dataType to "jsonp" instead of "xml" in $.ajax params, the call will fail in Chrome (parserError), but I can see the data returned from the webservice in the Debugger. My question is: is it possible to somehow override the default callbacks invoked when the response data is received? If not, what else can I do? I don't have access to the server running the webservice. In other threads about this issue I've read that doing the request on page load instead of as Ajax call works. However it's not clear to me what that means / how that's to be done. I appreciate any illumination on this!
JSONP is JSON with Padding, it loads the URL (GET only) as a <script>
tag, and assumes that the JSONP response contains a function call with the actual JSON as the first argument.
Most remote webservices, like Twitter, support a 'callback=' GET parameter. For example:
GET /my/jsonp/?callback=myFunction
And response should be a 'JavaScript' file with contents.
myFunction({"code": 200, "status": "OK"});
That's JSONP.