Escape plus(+) sign in URL
But when we pass a plus(+) sign in the escape() function it doesn't converts the plus(+) sign to the corresponding ASCII character. Rather it replaces the plus (+) sign with a space character. Which cause many issue during the AJAX call to the server side.
Also, if we are thinking to avoid escape() function and pass the string directly to then also it will not work.
When we are escaping a string before escaping that we will convert all the plus(+) sign with the corresponding ASCII character . Then during escape function call it will work like the normal way.
var strQueryString = "SELECT 1+1 FROM EMPLOYEES";
- escape(strQueryString).replace(new RegExp( "\\+", "g" ),"%2B") (will convert plus sign to ASCII)
- escape(strQueryString) (will not convert plus sign to ASCII)
You can simply see the difference by the above code.