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?