Friday, February 21, 2014

[javascript][Solved] Expected an identifier and instead saw '"'

Detailed Error Message :
Expected an identifier and instead saw '"' . Missing ";" before statement.

What's the matter ?
Finally found it's not related to any ";" as the error message mentioned.
The reason is I have used some wrong syntax,
I marked at the image as below:



This is a part of my code,
I made syntax which caused error in red.
So I highlight them in yellow:
case "remove":
case "remove1":
searchquery = prequery+'"'.encodeURIComponent($('#remove').val())+'"+-"'+encodeURIComponent($('remove1').val()).'"';
$('#search_query').html(searchquery.replace(/%20/g, '+'));
break;
case "and":
searchquery = prequery+'"'.encodeURIComponent($('#and').val())+'"+%2"'+encodeURIComponent($('and1').val()).'"';
        $('#search_query').html(searchquery.replace(/%20/g, '+'));
break;
For my case, change the . to + can fix the error
case "remove":
case "remove1":
searchquery = prequery+'"'.encodeURIComponent($('#remove').val())+'"+-"'+encodeURIComponent($('remove1').val())+'"';
$('#search_query').html(searchquery.replace(/%20/g, '+'));
break;
case "and":
searchquery = prequery+'"'.encodeURIComponent($('#and').val())+'"+%2"'+encodeURIComponent($('and1').val())+'"';
        $('#search_query').html(searchquery.replace(/%20/g, '+'));
break;

=======================================

My small Conclusion:

Don't exactly believe the error message, but look up the mistake near the position mentioned by error message .

No comments :

Post a Comment