I have a project that was initially built in Craft 3 and I'm upgrading it to Craft 4. I leverage ajax on one of the pages to save data to a user in the CMS. The following code worked in Craft 3 but no longer works in Craft 4. The ajax request submits correctly and the data is saved to the CMS but data.success
no longer returns true. What's the ideal way to handle an ajax pass/fail in Craft 4?
$.ajax({
contentType: false,
processData: false,
method: "POST",
url: '',
dataType: "json",
data: formData
}).done(function(data) {
if (data.success == true) {
console.log(data, 'success')
} else {
console.log(data, 'fail')
}
}).fail(function(data) {
console.log(data, 'fail')
});