我的JSON數據看起來財產以後這樣
[{"id":"299","calendar_id":"49","event_date":"2012-11-27","event_start":"2012-11-27 00:39:00","event_end":"2012-11-27 00:39:00","title":"description goes here","description":"","planned":"0","type_class":"General","type_data":"{\"frequency_type\":\"1\",\"frequency_x\":null,\"type\":\"14\",\"status\":\"23\"}"
Ajax請求從警予JSON獲取數據通過jQuery的
$.ajax({
url: "<?php echo $this->createUrl('path/to/file')?>",
dataType: 'json',
cache: false,
success: function(data) {
var out = "<span>";
$(data).each(function(){
out += this.title;
});
out += "</span>";
unplannedList.html(out);
}
var unplannedList = $('.col ul li');
這正是我需要追加我的數據,該數據顯示在頂部的列表。 'this'或'data'不起作用。從我粘貼的警報中獲取數據的正確方法是什麼?
你的小提琴完美,但不是我的代碼。如果我嘗試提醒$ .each(data,function(k,v){alert('in');}中的數據,它不會提醒任何事情。 alert。奇怪 –
做一個console.log(數據)每個以外,看看你是否收到一個JavaScript對象..然後做一個console.log(V),以確保你得到每個函數內的每個對象 –
console.log(數據)理想情況下應該顯示在螢火蟲控制檯窗口中的數據權?沒有什麼顯示在那裏,'>>>' –