问题
I know that using JSONP thechnique http://en.wikipedia.org/wiki/JSONP we can kinda make a cross domain Ajax Request.
But for this question that doesn't count as "pure and traditional".
I am only wondering if for native / hybrid apps also applies the "Same Origin Policy"
http://en.wikipedia.org/wiki/Same-origin_policy
There seems to be a lot of confusion in this matter.
A friend of mine swears that he connected Sencha Touch 2.3.1 + PhoneGap 3 to his back-end with "Ajax" proxies which I find hard to believe (proxies should be JSONP IMO), or this only requires special server config since Same Origin Policy is never applied 'cos browsers never get involved?
I know this kinda question might not be in the spirit of SO but I think a good answer on this subject would help a lot of people since I've not been able to find one.
Best regards @code4jhon
回答1:
PhoneGap apps run in webview not in browser, so cross origin is not an issue with PhoneGap apps, you can perform AJAX calls to any URL.
The only thing to care of is that there is a white list parameter "access origin" in config used to restrict the access to some specific URLs.
For older PhoneGap versions, the default setting for access origin was localhost, but now it is set by default to "*" which allows access to any URL.
No need for JSONP or cors headers with PhoneGap.
来源:https://stackoverflow.com/questions/21915443/are-pure-and-traditional-ajax-requests-possible-on-native-hybrid-mobile-apps