mvasco mvasco - 1 month ago 19
Javascript Question

Uncaught SyntaxError: Invalid or unexpected token in JavaScript

I am getting this error message at the console for line:

var dataString = \'search=\'+ searchid;

at following script:

var searchid = $(this).val();
var dataString = \'search=\'+ searchid;
type: "POST",
url: "classes/search.php",
data: dataString,
cache: false,
success: function(html)
}return false;

What is wrong there?


There is no need to escape quotes in this situation:

var dataString = 'search=' + searchid;

And as commented the next line also has issue. Remove the slashes.