I have a form, I am using serialize() to get the values from the form and post it in ajax. But I am getting internal server error. Below I have attached the code
var formData = $('#loginForm').serialize();
var request = $.ajax({
type: "POST",
url: "/Ajax/Register",
data: formData,
contentType: "application/json; charset=utf-8",
dataType: "json",
});
The formData produces username=aaa&password=bbb. I found that formData is the problem. If I use data : '{"username":"aaa","password":"bbb"}'
it is working. Now I have to parse the data through hard coding it. is there any method that does this or resolves this issue?? and also If I change type:GET
it works. but that's not the right way.