weixin_33670713 2015-05-27 17:00 采纳率: 0%
浏览 73

POSTDATA错误的JSON格式?

I have an AJAX request which sends JSON data to process.php, but it sends the parameters in the wrong format, x-www-form-urlencoded. I would like to send with JSON format.

Here is my code, I don't know where the problem is.

 $.ajax({
          type:"POST",
          url:"process.php",
          contentType: "application/json",
          dataType: "json",
          async: true,
          data: {
              country: json[i][0],
              competition: json[i][1],
              club: json[i][2]},

            success: function(){ alert("data")},
          error: function(){ /*alert("error")*/}
        });
    }
});

The result of the post request in Tamper data:

Host=localhost User-Agent=Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Firefox/38.0 Accept=application/json, text/javascript, /; q=0.01 Accept-Language=en_EN,en;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding=gzip, deflate Content-Type=application/json; charset=UTF-8 X-Requested-With=XMLHttpRequest Referer=localhost/football/process.php Content-Length=61 Connection=keep-alive Pragma=no-cache Cache-Control=no-cache POSTDATA=country=America&competition=Copa+Libertado&club=Boca+Juniors

Why are my parameters sent in x-www-form-urlencoded format instead of JSON?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败
    • ¥15 树莓派5怎么用camera module 3啊
    • ¥20 java在应用程序里获取不到扬声器设备
    • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
    • ¥15 Attention is all you need 的代码运行