Passing Strings Having Special Characters
I am trying to pass strings with spaces and special characters, but its getting error and nothing is working. e.g.
&gossip");' src="images/plus.png" />
JavaScript
Use encodeURIComponent(s).
var url = "addKeyword.php?uid=" + encodeURIComponent(user_id) + "&categoryId=" + encodeURIComponent(categoryId) + "&keyword=" + encodeURIComponent($("#keyword_" + categoryId).attr("value"));
Solution 2:
try
<img onclick="addKeyword('<?php echo htmlspecialchars('celebritynews&gossip'); ?>')" src="images/plus.png" >
Solution 3:
Assuming you are writing this text to the page, you can use htmlspecialchars
to ensure it is properly escaped in the HTML.
For example:
<?php echo htmlspecialchars("celebritynews&gossip"); ?>
Does that help?
Post a Comment for "Passing Strings Having Special Characters"