POST请求失败在Firefox

POST请求失败在Firefox

本文介绍了使用jQuery AJAX HTTPS POST请求失败在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有记录在一个HTML表的每一行的删除链接一个简单的列表。删除链接拍摄过一个AJAX POST请求到一个固定的URL,看起来像: /删除/记录/ 5

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"

Ajax请求是使用jQuery的阿贾克斯()使用HTTPS的服务器上运行时,用POST消息调用创建。此调用失败在Firefox 3在OSX / Windows的体系结构。它适用于所有其他的浏览器我测试过(OSX / Windows的:Chrome浏览器,Safari浏览器,IE7)

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.)

该请求是从HTTPS站点来来往往同一个HTTPS站点。但我认为某处过程中的原始请求的HTTP开始关闭,还有我们的服务器重定向尝试从基于HTTP> HTTPS发送和Firefox拒绝重定向为某种类型的伪造的。

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.

有没有人有经验做阿贾克斯()上的HTTPS站点与Firefox JQuery的电话?我注意到一些奇怪的地方,如果要求有?变种= XXX 中的URL参数,请求似乎工作更经常然后如果没有这些变量。

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.

推荐答案

听起来你得到一个HTTP 411错误。。如果你发送一个此错误可能发生没有任何数据POST 要求

Sounds like you're getting an HTTP 411 error.. This error can happen if you're sending a POST request without any data.

要解决此问题,添加一个空对象( {} )的数据属性您的要求:

To fix this, add an empty object ({}) to the data property to your requests:

$.ajax({
    url: url,
    type: 'POST',
    data: {}, // <- set empty data
    success: function(data, textStatus) {
        // do something
    }
});

这篇关于使用jQuery AJAX HTTPS POST请求失败在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 18:56