Reputation: 127
I have tried with the following code:
$.get("/a.php?op=ajax§ion=b&cat_name=" + name.replaceAll("%", "")) + "&a=" + aname.replaceAll("%", "_"),function(resp) {
});
In my name
value contains more than one &
symbol. At that time I couldn't pass the full value because of when one &
symbol occur then, it breaks my data.
For example my name = 'DisplayPort & Mini DisplayPort Connector'
I got only 'DisplayPort'.I didn't get the remaining part.
Upvotes: 0
Views: 200
Reputation: 781141
Use encodeURIComponent()
to encode special characters in query parameters. If you do this, you also don't need to remove %
, it will encode them properly.
$.get("/a.php?op=ajax§ion=b&cat_name=" + encodeURIComponent(name) + "&a=" + encodeURIComponent(aname),function(resp) {
});
Upvotes: 1