I am using jQuery ajax to call a coldfusion query that I have verified is working and submitting to the sql database. I am receiving this JSON error though: SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 5 of the JSON data
Everything is still posting to the database correctly but the error is causing it to not go the successful route where the window reloads. Does anyone notice what I may be doing wrong here?
JS
$('#employeeLoggedOut').on('submit', function (e) {
e.preventDefault();
//alert($(this).serialize());
console.log($(this).serialize());
$.ajax({
// the location of the CFC to run
url: "proxy/Completed.cfm",
// send a GET HTTP operation
type: "post",
// tell jQuery we're getting JSON back
dataType: "json",
// send the data to the CFC
data: $('#employeeLoggedOut').serialize(),
// this gets the data returned on success
success: function (data) {
console.log(data);
window.location.reload();
},
// this runs if an error
error: function (xhr, textStatus, errorThrown) {
// show error
console.log(errorThrown);
}
});
});
});
CF
<cfset session.dealerwork.completedname = form.CompletedName >
<cfoutput>#SerializeJSON(session.dealerwork.completedname)#</Cfoutput>
<cfset session.dealerwork.idtocomplete = form.selectedRow >
<cfoutput>#SerializeJSON(session.dealerwork.idtocomplete)#</Cfoutput>
<cfquery name="completeBatch">
UPDATE dbo.Dealer_Track_Work
SET Date_Complete = getDate(),
Closed_by = <cfqueryparam value="#session.dealerwork.completedname#" cfsqltype="cf_sql_varchar">
WHERE id = <cfqueryparam value="#session.dealerwork.idtocomplete#" cfsqltype="cf_sql_integer">
</cfquery>