Search code examples
jqueryajaxescapingmagic-quotes-gpc

Jquery Ajax escapes strings despite magic_quotes_gpc = off


Data I post via jQuery Ajax are being escaped even when magic_quotes_gpc = off on the server.

Getting data directly from $_POST (not using ajax) works fine, unescaped. but sending them through ajax escapes them.

$.ajax({
url: 'includes/updateDb.php',
type: 'POST',
data: {
    id:  $this.attr('data-id'),  
    text: $this.html()
}
});

test's -> test\'s

Is that a feature or a bug? How should I proceed? Strip the strings via PHP on the server?


Solution

  • It turned out that despite phpinfo() showed that magic_quotes_gpc were turned off, they were indeed on. It was a shared-hosting feature that caused php.ini to affect only the topmost folder. I didn't realize this.

    Apologies and thanks for help -)