2

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?

Dror 'Yitzhakov
  • 280
  • 5
  • 15
  • 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 – Dror 'Yitzhakov Jan 10 '12 at 21:34
  • You don't need to set the `$.support.cors` or `$.mobile.allowCrossDomainPages` properties because your request is not originating from a domain, therefore cross-domain restrictions do not apply. – Jasper Jan 10 '12 at 21:57

1 Answers1

3

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

Dror 'Yitzhakov
  • 280
  • 5
  • 15