Syntaxerror: expected Expression, got '<' in AJAX call

Asked

Viewed 537 times

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);
      }
   })
}
  • 1

    dataType: 'script' expects a Javascript code. There is some wrong return on your urlCreateBH. It’s probably returning 404. You need to check this in the newtwork tab of Chrome.

  • Try to add inside your ajax a error: function(status, error, e){&#xA; console.log(error);&#xA; console.log(status);&#xA; console.log(e);&#xA;} and check your browser console.

  • what are the values of $('#monthEW').val() and $('#monthEW').val()? If they’re not numeric they need to be in quotes.

  • If you want to pass data in the post, change the dataType for json and edit the object as if it were a json object.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.