I am not able to see the data from my JavaScript in my Controller but I DO see the value in my Request Header. I have no clue why this isn't working....
JavaScript
$('#Save').click(function (e) {
if (document.forms[0].checkValidity()) {
e.preventDefault();
$.ajax({
url: "/Home/SaveDetails",
dataType: "json",
data: JSON.stringify({ data: "test" }),
type: "POST",
contentType: "application/json;charset=utf-8",
success: function (result) {
if (result > 0) {
alert("Worked!);
} else {
alert("There was an issue.");
}
},
complete: function () {
alert("Completed!");
},
error: function (jqXHR, textStatus, errorThrown) {
// Handle error.
alert(errorThrown);
}
});
}
else {
alert("Form is not valid");
}
});
Controller
[HttpPost]
public ActionResult SaveDetails(string value)
{
return Json(true, JsonRequestBehavior.AllowGet);
}
If I modify the url parameter of the ajax request above to include something like > url: "/Home/SaveDetails?username=" + 'sampleUser' I can see that data in my controller but no matter what approach I take I don't see anything sent from the ajax request using the data parameter.