par
Agent5acad27 » 19 juin 2018, 23:18
Par exemple, je fait ceci:
$testjson['title'] = '<math xmlns="http//:www.w3.org/1998/Math/MathML">';
Puis en js:
var data = JSON.parse('<?php echo json_encode($testjson) ?>');
Ce qui est affiché au client est:
var data = JSON.parse('{"title":"<math xmlns=\"http\/\/:www.w3.org\/1998\/Math\/MathML\">"}');
Et j'obtiens cette erreur:
Uncaught SyntaxError: Unexpected token h in JSON at position 23
Cordialement