【发布时间】:2010-06-14 06:42:28
【问题描述】:
我有一个如下的 jquery 脚本:
$.ajax({
type: "GET",
url: "http://www.site.com/v4/ajax/get_song_info.php",
data: ({id : song_id }),
dataType: "json",
success: function(data)
{
alert( "Data: " + data );
}
});
以及相关的php页面:
<?php
include_once '../connect.php';
$song_id = $_GET['id'];
$query = mysql_query("SELECT * FROM songs WHERE id = '$song_id' LIMIT 1");
$song = mysql_fetch_row($query);
$song_info = array( htmlentities($song[3]) , htmlentities($song[4]) );
header('Content-Type: application/json');
echo json_encode($song_info);
?>
当我在浏览器中单独调用 php 时,它会返回如下内容:["Peaches","I Feel Cream (Proxy Remix)"]
但是,当我调用 jQuery 时,我的警报显示 'Data: null'
【问题讨论】: