Last active
November 16, 2019 04:55
-
-
Save syuji-higa/fb6a38b24b00b9038c14bd0e3c3e0e92 to your computer and use it in GitHub Desktop.
PHP - get data with Ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || | |
$_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest') { | |
die(json_encode(array('status' => "Invalid call."))); | |
} | |
$value = array( | |
array('id' => 0, 'name' => 'taro', 'age' => '25'), | |
array('id' => 0, 'name' => 'jiro', 'age' => '20'), | |
); | |
header('Content-Type: application/json; charset=UTF-8'); | |
header('X-Content-Type-Options: nosniff'); | |
echo json_encode($value, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment