Detect JSON Ajax requests by the response content-type (like is done with XML). Fixes #5709.

This commit is contained in:
Rick Waldron 2010-01-05 19:48:16 -05:00 committed by jeresig
parent 230614b4df
commit 787f271052
3 changed files with 26 additions and 2 deletions

View file

@ -1,9 +1,13 @@
<?php
error_reporting(0);
if ( $_REQUEST['header'] ) {
header("Content-type: application/json");
}
$json = $_REQUEST['json'];
if($json) {
echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]';
} else {
echo '{ "data": {"lang": "en", "length": 25} }';
}
?>
?>