我正在尝试通过 ajax 发布 json 数据。 json 数据包含一个大的 html 表。但是,此 POST 请求转换为 GET 请求,我收到错误 414(请求 URI 太长)。我知道jsonp POST请求会转成GET,但为什么我的json请求会转成GET呢?
$.ajax({
url: 'api.php',
method: 'POST',
data: {
'call': 'emailSalesReportToAdmin',
'tableHtml': $('#tblSalesReport').parent().html()
},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
},
});
最佳答案
是的,对于旧版本,请使用type:'POST' 而不是method:'POST'
如 jQuery documentation 所述
type (default: 'GET') Type: String An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0.
关于javascript - jQuery - Ajax POST 请求转换为 GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51396647/