Despite my efforts to resolve the "Invalid JSON primitive" issue by reading various references, I have not been able to find a solution. As a last resort, I am sharing my code in its simplest form and still encountering the error. See below for the minimal code snippet:
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 attempted using the following dataObject replacement:
var dataObject = {
'FirstName': 'ES',
'LastName': 'Dictor'
};
Unfortunately, this did not change the results of the error message.
Regardless of my attempts, the Chrome console consistently shows:
response:
Object {readyState: 4, responseText: "<!DOCTYPE html>
↵<html>
↵ <head>
↵ <titl…nStep step, Boolean& completedSynchronously)
↵-->", status: 500, statusText: "Internal Server Error"}
Inspecting the response.responseText reveals:
<!DOCTYPE html>
<html>
<head>
<title>Invalid JSON primitive: FirstName.</title>
At this point, after exhausting all possible solutions, it seems like there may be a simple fix that I am overlooking. Hopefully, someone can identify what I am missing.