ArcGIS Server Javascript API - Search with apostrophes
We recently came across an issue with our queryTask and findTask functions when using apostrophes. If you submit a query or find task and the search text contains an apostrophe, you will get the following result:
Unable to perform query. Please check your parameters.
This is actually an issue with SQL Sever and not the Javascript API. To get SQL Sever to recognize the single apostrophe, you need to replace the single apostrophe with a pair of apostrophes.
To fix this issue, we used the following javascript code:
var county = dojo.byId('countySelect').value;
county = county.replace("'","''");
This should be done for any queryTask or findTask where the data being searched contains apostrophes.
Follow Us On Twitter
