jQuery Mobile + PhoneGap on iphone fails to loadPa

2019-04-14 05:43发布

问题:

I am trying to write a simple phonegap + jqm app that gets a page from remote server.

$.mobile.loadPage("http://mydomain.com/Mobile/MyPage.aspx")
          .done(function () { alert('done'); })
          .fail(function () { alert('fail'); });
 });

I set the following options:

$.support.cors = true;
$.mobile.allowCrossDomainPages = true;

Added the following header:

Access-Control-Allow-Origin:*

Everything works fine when I try it in desktop browsers (ff/chrome/safari) but it doesnt work on my iphone or in the iphone simulator.

Any ideas?

回答1:

Ok it turned out to be something silly: For cross domain request to work in iPhone (using phonegap and jquery mobile) you have to do the following: In xCode: Navigate to [projectName] -> Support Files -> phonegap.plist Under External Hosts add a new string with the value * Or add your exact domain