I've read every reference to "Invalid JSON primitive" with no success, so I have no choice but to post my own. I have reduced my code down to the bare minimum and am still getting the error. Here's the "bare minimum":
var dataObject = {
'FirstName': $('#FirstName').val(),
'LastName': $('#LastName').val()
};
$.ajax({
type: 'POST',
url: '@Url.Action("Submit", "Home")',
contentType: 'application/json;',
dataType: 'json',
data: dataObject,
success: function (result) {
debugger;
alert('Success');
},
error: function (response) {
debugger;
alert('Error');
}
});
I have also tried replacing the dataObject with:
var dataObject = {
'FirstName': 'ES',
'LastName': 'Dictor'
};
Giving no change to my results.
No matter what I do I get (Chrome console):
response:
Object {readyState: 4, responseText: "<!DOCTYPE html>
↵<html>
↵ <head>
↵ <titl…nStep step, Boolean& completedSynchronously)
↵-->", status: 500, statusText: "Internal Server Error"}
and if I look at response.responseText I see:
<!DOCTYPE html>
<html>
<head>
<title>Invalid JSON primitive: FirstName.</title>
I believe I've tried everything at this point, so it's probably something simple that I'm just missing. Hoping that somebody can see what I can't.
JSON.stringify()on the data? Something likedata: JSON.stringify(dataObject)?