I try to send list of object like [{"name":"Vasya"},{"name":"Lila"}]
It's my code:
$.ajax({
url: url
, type: 'POST'
, contentType: 'application/json'
, data: data
, success: function(response) {
showPopup(response.successMessage);
}
});
Where alert(JSON.stringify(data)); shows: [{"name":"Vasya"},{"name":"Lila"}]
But when I am checking my request in chrome debug mode the request contains undefined= instead correct data.
What I do wrong? Is this syntax incorrect according to JSON?
contentTypeoption to send the data asx-www-form-urlencoded, or stringify the object as JSON to actually send JSON, now you're telling the server that whatever you're sending should be valid JSON, but you're sendingx-www-form-urlencodedname=Vasya&name=Lilathough? OP mentioned Chrome is sending it asundefinedinstead.