2
我有麻煩試圖找出爲什麼我的JSON data.email響應返回null。任何人都可以建議嗎?jQuery的Ajax形式與JSON響應
//javascript
$.ajax(
{
type: 'POST',
url: 'process.php',
dataType: 'json',
data: { email : "[email protected]" },
success: function(data)
{
alert("result = "+data.email);
}
});
//php (process.php)
if ($_POST['email'])
$return['email'] = $_POST['email'];
else
$return['email'] = "no email specified";
echo json_encode($return);