php - 在 JQuery AJAX POST 上...请求失败 : URI too long (longer than 8190)

标签 php jquery ajax apache post

我得到了错误:

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

我已经在 StackOverflow 上看到了与此相关的其他帖子。这些帖子推荐:

  • 不更改 Apache 设置(同意)
  • 使用post,而不是get
  • 不在帖子中使用 jsonp

我正在使用 jQuery 的 AJAX 来发布:

    $.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);}
});

老实说,我认为这是自动的,但由于您的网址太长,值得一试。

关于php - 在 JQuery AJAX POST 上...请求失败 : URI too long (longer than 8190),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8542061/

相关文章:

php - 我想添加一个当我的用户失去互联网连接时显示消息的 facebook 功能

javascript - (jQuery.js 错误)未捕获错误 : Syntax error, 无法识别的表达式:[href=#]

PHP+AJAX+MYSQL 最后一个表单条目在 MySql 中创建一个新列

php - 处理多维 $_FILES 数组

php - 尝试使用表单和 php 进行 INSERT INTO 查询,但数据库未更新记录

php foreach 静态函数

javascript - 使用 jQuery concat 添加新行

php curl 能够登录网站但登录后不显示任何数据

javascript - 我的所有功能什么时候完成?

javascript - 按钮 "Search books"的 onclick 函数不起作用,因为我没有收到任何警报...函数 SendInform() 未被调用