PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I get an Error: SyntaxError: JSON.parse: unexpected character, IF I use any of the the first two //commented lines.
But if I remove them, it works. Whats the problem with these lines? What can / cant I use in file with JSON...
<?php
//print_r($_POST); - this line gives an error
//echo " HELLLOOOOOO WORLD - THIS IS AN AJAX TEST"; - this line gives an error
$json = array(
'name' => 'HOSSAIN',
'age' => '22',
'location' => 'DHAKA'
);
echo json_encode($json);
?>
the two lines are outputting something, so that is not an valid json output anymore.
Your javascript ajax handler awaits an valid json response from the server.