PHP
<?php
header("Content-type: application/json") ;
echo json_encode(array("reply" => "SOME_TEXT")) ;
?>
it echos this ->
{"reply":"SOME_TEXT"}
Javascript
<script>
$.get("script.php" , function(data) {
var reply = JSON.parse(data) ;
}) ;
</script>
JS throws unexpected token in JSON
. But it will working fine if I replace the header in PHP code with header("Content-type: text/javascript") or "text/plain".