$('.editBtn').click(function(){//EDIT BUTTON EVENT
$.getJSON('edit.php?url='+encodeURI($(this).siblings('a').attr('id'))+'&action=edit',function(data){
$.each(data, function(key, val) {
alert(key+': '+val);
});
});
});//EDIT BUTTON END
,這裏是有問題的PHP部分:JSON冗餘數據檢索
elseif($_GET['action']=='edit'){
$output=$mysql->getDb()->query("select * from video
where url='{$_GET['url']}'")->fetchAll();
header("content-type: application/json");
echo json_encode($output[0]);
}
什麼情況是,當點擊.editBtn
按鈕,警報彈出0:value0, 1:value1,...
,然後再進入,但在某種程度上,我只希望它要name0:value0, name1:value1,...
發生了什麼事?
p.s. PHP的獨立運行:這裏返回
{"url":"www.vimeo.com\/20721308","0":"www.vimeo.com\/20721308","title":"Dis-patch Festival R.I.P.","1":"Dis-patch Festival R.I.P.","description":"Sadly, the last goodbyes to the Dis-patch Festival Belgrade edition in this tribute \"R.I.P.\" video collage. The end is always the beginning...","2":"Sadly, the last goodbyes to the Dis-patch Festival Belgrade edition in this tribute \"R.I.P.\" video collage. The end is always the beginning...","country":"serbia","3":"serbia","postDate":"2011-05-07 05:56:04","4":"2011-05-07 05:56:04","views":null,"5":null}
你可以獨立運行edit.php並粘貼輸出嗎? – 2011-05-08 22:07:32
是的。再看看上面的 – 2011-05-08 22:31:51
所以你說它正在運行並且提醒所有事情兩次?這一切似乎都對。也許你會連接兩次點擊處理程序?你有沒有發佈我們可以看到它的行動? – 2011-05-08 22:36:26