使用 jquery 的 AJAX https POST 请求在 Firefox 中失败
我在 HTML 表中有一个简单的记录列表,每行都有一个删除链接。 删除链接将 AJAX post 请求发送到固定 URL,如下所示:“/delete/record/5
”
AJAX 请求是使用 jquery 的 .ajax()
创建的在使用 https 的服务器上运行时使用 POST 消息进行调用。 此调用在 OSX/Windows 架构上的 Firefox 3 中失败。 它适用于我测试过的所有其他浏览器(OSX/Windows:Chrome、Safari、IE7。)
请求来自 https 站点并转到同一个 https 站点。 但我认为在这个过程中的某个地方,原始请求以 http 开始,并且我们的服务器上有一个重定向尝试从 http->https 发送它,而 Firefox 会拒绝该重定向,因为这是某种类型的伪造。
有没有人有过使用 Firefox 在 https 站点上进行 .ajax()
JQuery 调用的经验? 我注意到一些奇怪的地方,如果请求的 URL 中有“?var=xxx
”参数,则该请求似乎比没有这些变量的情况更频繁地工作。
I have a simple list of records in an HTML table with a delete link for each row. The delete link shoots off an AJAX post request to a fixed url that looks like: "/delete/record/5
"
The AJAX request is created using jquery's .ajax()
call with a POST message when running on a server that uses https. This call fails in Firefox 3 on OSX/Windows architectures. It works on all other browsers I've tested (OSX/Windows: Chrome, Safari, IE7.)
The requests are coming from an https site and going to the same https site. But I think somewhere during the process the original request starts off as http and there is a redirect attempt on our server to send it from http->https and Firefox rejects that redirect as some type of forgery.
Has anyone had experience doing .ajax()
JQuery calls on an https site with Firefox? I notice something odd where if the request has "?var=xxx
" arguments in the URL, the request seems to work more often then if it does not have those variables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来您遇到了 HTTP 411 错误。。 如果您发送不带任何
数据
的POST
请求,则可能会发生此错误。要解决此问题,请向请求的
data
属性添加一个空对象 ({}
):Sounds like you're getting an HTTP 411 error.. This error can happen if you're sending a
POST
request without anydata
.To fix this, add an empty object (
{}
) to thedata
property to your requests:这似乎不太可能……并不是我怀疑你。 但我建议下载 Wireshark 并观察您的 HTTP 流量,看看是否无法隔离问题。 您将能够将其他浏览器发送的请求与 FF3 发送的请求进行比较,并查看返回的响应类型。 如果确实是 jQuery 在 FF3 中无法正常运行的问题,您也许可以更改一些代码以使其正常运行。
That seems unlikely... not that I'm doubting you. But I would suggest downloading Wireshark and watching your HTTP traffic to see if you can't isolate the problem. You'll be able to compare the request sent by other browsers against the request sent out by FF3 and see what sort of response is coming back. If it is indeed a problem with jQuery not functioning correctly in FF3 you might be able to alter some of the code to work properly.
您可以安装 Firefox Live Headers 扩展,该扩展将允许您访问请求/响应中的所有信息。 这样你就会发现任何差异。
You can probably install the Firefox Live Headers extension that will give you access to all the information in your requests/responses. This way you'll be catch any differences.
您的 Firefox 上是否安装了任何插件或 GreaseMonkey 脚本?
我从未遇到过 HTTPS 上的 jQuery AJAX 请求问题。 如果您还没有看过的话,我建议您看一下 Firebug 出现的内容。
Do you have any plugins or GreaseMonkey scripts installed on your Firefox?
I have never had issues with jQuery AJAX requests on HTTPS. I'd suggest taking a look at what Firebug turns up if you haven't already.
通过发送一个空对象作为
data
参数,我让$.post
在 Firefox 中工作。 注意参数 2 的空括号:I got
$.post
to work in Firefox by sending an empty object as thedata
parameter. Notice the empty brackets for parameter 2: