I have made a phonegap plugin application on android. I am trying to send String value from Java Code to JavaScript using the sendJavaScript API
in Phonegap. But I am facing a problem. If the string contains a single quote, then sendJavaScript
does not work. Without single quote, it works perfectly fine. Following is the code, in the java file of Plugin class.
String result = "Any text except single quote ";
String SendJS = "javascript:" + SuccessCallBack + "('" + JSONObject.quote(result) + "')";
sendJavaScript(SendJS);
SuccessCallBack
- Callback function in the JavaScript.
result
- String to be passed to JavaScript Callback.
If the result string contains a single quote, then sendJavaScript does not work.
Any Suggestions?