允许在Safari和Chrome跨域请求?服务器响应与命令行参数 [英] Allowing cross-domain requests in Safari and Chrome? Server response vs. command line arguments

查看:2326
本文介绍了允许在Safari和Chrome跨域请求?服务器响应与命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Windows上的Safari跨域请求。我的Safari浏览器的版本是5.1.2。

I am trying to make cross-domain requests with Safari on Windows. My Safari version is 5.1.2.

这是一个经典的问题。我看了很多地方的Chrome和Safari允许跨域请求,只要服务器响应在响应中跟随着头

This is a classical question. I read in many places that Chrome and Safari allows cross domain requests as long as Server responds with the followin header in the response

Access-Control-Allow-Origin: *

我已经阅读这篇文章。 如何允许在Safari跨域请求? 和许多人对计算器的网站了。

I have read this post. How to allow cross-domain requests in Safari? and many others on the stackoverflow site too.

然而,他们没有回答我的问题。

However, none of them answers my question.

我有问题,Chrome和Safari浏览器进行跨域AJAX请求即使我从服务器发送必要的头后面。

I am having problems with Chrome AND Safari doing cross-domain AJAX requests even though I am sending the necessary header back from the server.

我终于跑酷容浏览器 - 禁用网络安全。然后它的工作。

I finally ran Chrome with "--disable-web-security". Then it worked.

我的问题:

1)我做的Safari浏览器是什么?我用一个类似的命令行参数?

1) What do I do with Safari? Do I use a similar command line argument?

2)更重要的是,我能有人告诉我跨域功能是否允许在Chrome和Safari浏览器在默认情况下,只要服务器的响应头还是必须确保

2) More importantly, can I someone please tell me whether cross-domain functionality is allowed in Chrome and Safari by default as long as server responds with the header or do I have to make sure that

一)服务器与头回应

二)浏览器开始用正确的参数。

b) browser is started with a proper argument.

推荐答案

我发现这个问题。阅读更多关于CORS帮助 html5rocks.com/en/tutorials/cors 。我意识到,我的请求,均触发preflight请求(选项)和服务器设置不正确地处理这些请求。这是造成preflight请求的原因是因为我使用jQuery和它增加了自定义头到我的请求。我修改了code至prevent除了这个额外的头和我的请求,不再需要preflight请求。现在,我没有禁用Web安全和正常工作。

I found the problem. Reading more about CORS helped html5rocks.com/en/tutorials/cors. I realized that my requests were triggering preflight requests (OPTIONS) and the server was not set up to handle these requests properly. The reason it was causing preflight requests was because I was using JQuery and it was adding a custom header into my requests. I modified my code to prevent addition of this extra header and my requests no longer needed preflight requests. Now I do not have to disable web security and it works fine.

这篇关于允许在Safari和Chrome跨域请求?服务器响应与命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆