I'm trying to pass the value of my inputs to a C# controller, but it always errors out when it tries to use the values because they are null.
$(document).ready(function () {
$(document).on('submit', '#form', function () {
var data = JSON.stringify({
'val1': $("#val1").val(),
'val2': $("#val2").val()
});
$.ajax({
type: "POST",
url: 'url',
contentType: "aplication/json",
data: data,
success: function () {
alert("It works")
},
error: function () {
alert("It failed");
}
});
return false;
});
});
Controller:
public IActionResult CheckForm(string val1, string val2)
{
//Do stuff
}
I appreciate any guidance on what step I am missing because as of now I have run out of ideas.


contentTypein your Ajax POST call just a typo?? It should beapplication/json(with twop- not just one)