How to enable Ajax loading of External URL(Cross Domain) in Jquery Mobile especially in Phonegap?

I am not quite sure how many of you had faced this is issue. But it was real a pain in the ass. I am was searching and searching but no use. Finally  I decided to rewrite what they wrote. Then the shocking surprise in the code that,  it was well documented so it was so easy . And my answer/issue was is already  answered.

Kidus to Jquery Mobile team for the fantastic work.


So the solution is,


$.mobile.allowCrossDomainPages = true;
// Simple right, but it was no where mentioned in there documents

I found them @

// Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR
// requests if the document doing the request was loaded via the file:// protocol.
// This is usually to allow the application to "phone home" and fetch app specific
// data. We normally let the browser handle external/cross-domain urls, but if the
// allowCrossDomainPages option is true, we will allow cross-domain http/https
// requests to go through our page loading logic.
isCrossDomainPageLoad = ( $.mobile.allowCrossDomainPages && documentUrl.protocol === "file:" && /^https?:/ ) != -1 ),

which developer can give such good documentation..

and finally I have completed my First Android App with Jquery Mobile and Phone Gap 🙂

Subin George
  • Kip Wurster

    Great post!