Ajax调用如何在移动应用程序(PhoneGap)中工作,但不是在PC浏览器中? [英] How Ajax call is working in mobile app (PhoneGap), but not in PC browser?
问题描述
Ajax调用服务器页面在移动应用程序中的工作原理(使用PhoneGap)。但是,当我在PC浏览器中从普通HTML页面运行相同的Ajax调用,它不工作。我想问题是跨域。
How Ajax call to server page works prefect in mobile app (using PhoneGap). But, When I run the same Ajax call from normal HTML page in PC browser it is not working. I guess the problem is cross domain. But, how it's work good in mobile app.
使用 JSONP
它在pc浏览器和移动应用程序中正常工作(使用PhoneGap)。但是在移动应用程序中, datatype =jsonp
也可以正常工作。
Using JSONP
it is working fine in pc browser and mobile app (using PhoneGap). But in mobile app without datatype="jsonp"
also working fine.
推荐答案
p>从 PhoneGap常见问题:
Q.我想为phonegap创建一个应用程序通过AJAX访问外部部署的Web服务。如何解决XmlHttpRequest的
跨域安全策略的问题?
Q. I want to create an application for phonegap to access externally deployed web services via AJAX. How can i resolve the issue with the cross-domain security policy of XmlHttpRequest?
A。跨域安全策略不会影响PhoneGap应用程序。由于html文件由webkit使用file://协议调用,因此安全策略不适用。
(在Android中,您可以通过编辑AndroidManifest.xml将android.permission.INTERNET授予您的应用)
A. The cross-domain security policy does not affect PhoneGap applications. Since the html files are called by webkit with the file:// protocol, the security policy does not apply. (in Android,you may grant android.permission.INTERNET to your app by edit the AndroidManifest.xml)
这篇关于Ajax调用如何在移动应用程序(PhoneGap)中工作,但不是在PC浏览器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!