var mydata = {
"one": {
"brand": "acer",
"cost": "212132"
}
}
$.ajax({
url: 'http://localhost',
type: 'post',
dataType: 'json',
data: JSON.stringify(mydata)
});
Above code is adding a colon to the data when i view the form send data in chrome dev tools. Is there anything wrong with the request?
You are viewing application/x-www-form-urlencoded parsed data. So Chrome is trying to establish key value pairs. Click "view source" near the "Form Data" heading in the network tab view. You will see your JSON without the colon.
Was the same for me. I did not see the colon when viewing source. BUT it did not work.
My solution was to add the missing contentType
$.ajax({
url: `url`,
contentType: "application/json",
type: "POST",
data: JSON.stringify(data)
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With