My view:
var token = $('input[name=__RequestVerificationToken]').val();
$.ajax({
url: '/Account/TryRegister',
type: 'post',
data: { '__RequestVerificationToken': token,
firstName: $('#FirstName').val(),
lastName: $('#LastName').val(),
email: $('#Email').val(),
password: $('#Password').val() },
success: function (outData) {
alert('Success!');
},
error: function () {
alert('Error!');
}
});
My controller:
[HttpPost]
[ValidateAntiForgeryToken]
public JsonResult TryRegister(string firstName, string lastName, string email, string password)
{
return Json(true); // TEMP!
}
If I remove firstName, lastName, email and password from both, it works, otherwise, it just doesn't get to the controller. What am I missing here (all fields really exist)?