I am trying to post my formdata via Ajax. But for some reason my payload is shown as a string and not as ajax:
shopName=asfd&street=afs&houseNo=asf&zipcode=&city=&country=&phoneNumber=&fax=&email=&website=
But it shouls appear as JSON. I have got no idea what could be wrong.
The code I have to compose my request is:
$('#shopForm').submit(function(e){
e.preventDefault();
var formData = $('#shopForm').serialize();
submitForm(formData);
});
function submitForm(formData)
{
$.ajax({
url: '/admin/shop/ajax',
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: formData,
success: function(response) {
console.log('succes');
console.log(response);
},
error: function(response) {
console.log('error');
console.log(response);
}
});
}
Any help is well appreciated.
Thanks.
EDIT 1
When changing data: formData,
tot data: JSON.Stringify(formData),
The payload changes to
shopName=asfd&street=afs&houseNo=asf&zipcode=&city=&country=&phoneNumber=&fax=&email=&website= No Properties