Skip to content
Advertisement

How to escape and remove backslashes from url after ajax call back?

In php I tried:

$link = get_permalink(icl_object_id(349,'page',false, $lang));
$link = str_replace("n", "", $link);
echo json_encode(stripslashes($link));

But I still get

"https://example.com/it/jiku/jikubox/le-mie-infografiche/"

Advertisement

Answer

You are encoding the URL as JSON, so use a JSON parser (such as JSON.parse(string) or one built into your Ajax library).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement