POSTDATA错误的JSON格式?

时间:2015-05-27 17:00:23

标签: php ajax json

我有一个AJAX请求,它将JSON数据发送到process.php,但它以错误的格式发送参数,x-www-form-urlencoded。我想用JSON格式发送。

这是我的代码,我不知道问题出在哪里。

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

篡改数据中的发布请求结果:

  

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 =科帕+ Libertado&安培;俱乐部=博卡拉+青年

为什么我的参数以x-www-form-urlencoded格式而不是JSON格式发送?

0 个答案:

没有答案