I have encountered a problem with my code that I cannot seem to resolve. Despite the JSON data being successfully sent to the backend and processed correctly, the success function of the call is never triggered.
Here is the snippet of my function:
RegistrationForm.prototype.sendCode = function(url, error) {
if (accessCode){
return $.ajax({
url: url,
type: 'POST',
data: JSON.stringify({"vouchercode": accessCode}),
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function(data){
//success case here. never fires
},
error: function(xhr, ajaxOptions, err, error){
console.log(err);
console.log(accessCode);
}
});
}
Upon logging the error in the AJAX error function, I receive the following message: SyntaxError: Unexpected token <