这是我经历过后的疑问
如何在使用jsonp代理时发送标头?
和
Ajax调用如何在移动应用程序(PhoneGap)中运行,而不是在PC浏览器中运行?
据此,我们可以在移动设备中使用json代理而不是jsonp,但不能在桌面浏览器中使用。 这听起来不错但我的问题是我使用我的桌面作为开发环境和浏览器是测试和调试我正在做的任何事情的最快方法但是如果我使用json代理这将因为跨域问题而无法工作。 请提供一些方法,以便我可以在桌面上轻松开发和调试应用程序。
我的工作站有Ubuntu操作系统,我使用Chrome浏览器进行测试。
This is my doubt after going through
How to send headers while using jsonp proxy?
and
How Ajax call is working in mobile app (PhoneGap), but not in PC browser?
As per this we can use json proxy instead of jsonp in mobile but not in desktop browser. This sounds good but my problem is I am using my desktop as develop environment and browser is quickest way to test and debug whatever I am doing but if I use json proxy this won't work because of cross domain issues. Please suggest ways such that I can easily develop and debug application on my desktop itself.
My workstation has Ubuntu OS and I use Chrome browser for testing.
最满意答案
我认为出于开发目的,您可以在浏览器中禁用跨域策略,如此处所示 。
为您桌面上的Chrome浏览器创建快捷方式 将以下标志添加到快捷方式--disable-web-security要么
您可以设置您的开发服务器以允许此处给出的跨域请求或[此处]
1 。 将以下标题添加到您的响应Access-Control-Allow-Origin: *
I think for the development purpose you can disable cross domain policy in your browser as given here.
create a short cut for the chrome browser in you desktop add the following flag to the short cut --disable-web-securityOr
You can setup your dev server to allow cross domain requests as given here or [here]
1. Add the following header to your response Access-Control-Allow-Origin: *
更多推荐
发布评论