I have a Drupal web app that uses Ajax; the Ajax function, sometimes, needs to pass string as parameters to a Drupal function as
$.ajax({url: "index.php?q=get_value/"+encodeURIComponent(value),
When the value contains a slash it is not recognized from the Drupal function made as
function get_value($value) {
print urldecode($value);
For example, if the passed string is ABC/123 , get_value prints only ABC
How can i solve this problem passing slashes and getting the entire string from PHP/Drupal?
Use %2f
instead of /
as:
$.ajax({url: "index.php?q=get_value" + "%2f" + encodeURIComponent(value),
[reference], See Section 2.2
Or, a more readable alternative:
$.ajax({url: "index.php?q=" + encodeURIComponent("get_value/"+value),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With