I recently added JSON content types to all server code that was returning JSON. i.e. header(‘Content-Type: application/json’); I also have a lot of script which is expecting only true/false or 1/0. I recognize I do not need to specify a content-type, however, am curious if it is best practice and I should do so. Please advise. Thank you
My Javascript for non-JSON ajax
$.post('file.php',obj,
function (status) {
if(status==1) {alert('do this');}
else{alert('do that');return false;}
});
file.php
<?php
header('Content-Type: ???/???');
echo(1);
?>
1 Answer