0
在我的項目中,我使用JQuery week calendar plugin。我調用一個php腳本來檢索數據並在calandar中顯示它。下面是我的代碼JQuery Week Calendar問題
var id = 3;
var type = "c";
var dataString = "id=" + id + "&t=" + type;
$.ajax({
type:"post",
url:"actions/client.php",
data: dataString,
dataType:"json",
success: function(data){
alert(data);
}
});
在PHP:
function getCalendarData($appoint_id){
$retunArray = array();
$sql = "SELECT id, appoint_start, appoint_end, total FROM account WHERE id = '".$appoint_id."'";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result)){
$retunArray[] == $row;
}
echo json_encode($retunArray);
}
它給了我一個500錯誤。有沒有人使用它之前與PHP。任何人都可以幫助我從數據庫中獲取數據並顯示嗎?任何替代方法比這更好
謝謝
您正在使用哪個版本的PHP? json_encode does not work PHP <5.2 http://abeautifulsite.net/blog/2008/05/using-json-encode-and-json-decode-in-php4/ – Chumillas 2011-12-16 11:16:17
json_encode正在工作,我的PHP版本是5.3+和我剩下的表單內容都是通過json發送和檢索的,所以它不是一個問題 – Mujahid 2011-12-16 11:58:57