php – 关于JQuery AJAX POST …请求失败:URI太长(超过8190)

我收到了错误

请求失败:URI太长(超过8190)

我在StackOverflow上看过其他帖子.这些帖子建议:

>不更改Apache设置(同意)
>使用post,而不是获取
>不使用jsonp与帖子

我正在使用jQuery的AJAX来POST:

    $.ajax({
        url: "test.PHP",
        dataType: "json",
        data: paras,
        type: "POST",
        success: function(ret){callback(ret);}
    });

这是我的印象你可以使用json而不是jsonp.正确?如果是这样,为什么我仍然会收到错误

解决方法:

您应该尝试将proccessData设置为false.

来自文档:

By default, data passed in to the data option as an object
(technically, anything other than a string) will be processed and
transformed into a query string, fitting to the default content-type
“application/x-www-form-urlencoded”. If you want to send a
DOMDocument, or other non-processed data, set this option to false.

所以要防止数据被添加到url:

$.ajax({
    url: "test.PHP",
    dataType: "application/json",
    data: paras,
    type: "POST",
    proccessData: false, // this is true by default
    success: function(ret){callback(ret);}
});

老实说,我认为这是自动的,但由于你的网址太长,所以值得一试.

相关文章

IE6是一个非常老旧的网页浏览器,虽然现在很少人再使用它,但...
PHP中的count()函数是用来计算数组或容器中元素的个数。这个...
使用 AJAX(Asynchronous JavaScript and XML)技术可以在不...
Ajax(Asynchronous JavaScript and XML)是一种用于改进网页...
本文将介绍如何通过AJAX下载Excel文件流。通过AJAX,我们可以...
Ajax是一种用于客户端和服务器之间的异步通信技术。通过Ajax...