jQuery Mobile + PhoneGap on iphone fails to loadPage

江枫思渺然 提交于 2020-01-01 17:08:48

问题


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



来源:https://stackoverflow.com/questions/8810522/jquery-mobile-phonegap-on-iphone-fails-to-loadpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!