I have the following code:
var form = new FormData();
form.append('user',$("#user").val());
form.append('password',$("#password").val());
var data = JSON.stringify($(form).serialize());
but the var 'date' is getting null, look at the example: link
The intention is to send this data using $ .ajax:
$.ajax({
url: "http://localhost:29199/default.aspx?tipo=autenticar",
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
myXhr.upload.addEventListener('progress', function (s) {
console.log('PROGRESSO', s);
}, false);
}
return myXhr;
},
success: function (a, b, c) {
console.log('SUCESSO', a, b, c);
},
error: function (a) { console.log('ERROR', a); }
});
On the server side I already have a structure to receive json and deserializes it into an object.