0
Hello
I have an error in an AJAX call in my Javascript. For some reason, it does not arrive at the function in my Controller and gives the following error: Syntaxerror: expected Expression, got '<'.
This function is called as soon as I click on a Modal button. It serves to create the data of an already created Datatable.
function EWBuild() {
$.ajax({
url: urlCreateBH,
data: { year: $('#findYearBH').val(), inputType: 1, month: $('#monthEW').val() },
dataType: "script",
type: 'POST',
success: function (result) {
CreateTableEW(result);
}
})
}
dataType: 'script'
expects a Javascript code. There is some wrong return on yoururlCreateBH
. It’s probably returning 404. You need to check this in the newtwork tab of Chrome.– Wallace Maxters
Try to add inside your ajax a
error: function(status, error, e){
 console.log(error);
 console.log(status);
 console.log(e);
}
and check your browser console.– Rhuan Dornelles
what are the values of
$('#monthEW').val()
and$('#monthEW').val()
? If they’re not numeric they need to be in quotes.– Leandro Angelo
If you want to pass data in the post, change the
dataType
forjson
and edit the object as if it were a json object.– Máttheus Spoo