mvasco mvasco - 1 year ago 147
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download