PHP version is 5.6.2
When sending a JS-object, why do strings end up escaped in PHP?
Here is my JS-code:
$.ajax({
url: url,
type: 'POST',
data: {obj: obj},
success: function(data) {},
error: function(req, status, error){},
timeout: 20000
});
All st'rin'gs end up like st\'rin\'gs in PHP. Of course I can stripslashes but what's the proper way of doing this?
Solution for everybody in the same situation, who checked and debugged and still can't find a solution: If you're using Wordpress, that's the cause. WP escapes all $_POST-variables automatically and since this AJAX was posted against wp_ajax.php, it was escaped. I took the easy way out and did:
stripslashes_deep($_POST['obj'])