1
我有以下腳本,我要調試:螢火蟲的JavaScript/jQuery的調試
function getTabFrame() {
$.ajax({
url: 'get_tab_frame.aspx?rand=' + Math.random(),
type: 'GET',
dataType: 'json',
error: function(xhr, status, error) {
//alert('Error: ' + status + '\nError Text: ' + error + '\nResponse Text: ' + xhr.responseText);
},
success: function(data) {
$("#divTabsDropdown").empty();
$.each(data, function(index, item) {
// create tabs with custom ids
$("#tabs").tabs("add", "get_tab_content.aspx?tab=" + item.key, item.value)
.find(">ul>li:last")
.attr("id", "tab_group_" + item.key);
// creates the buttons
$("#divTabsDropdown").append("<div class='item custom_group' id='tab" + item.ordering + "'>" + item.value + "</div>");
// link buttons with tabs
$("#tab" + item.ordering).live('click', function() {
$("#tabs").tabs("select" , $("#tab_group_" + item.key).index());
});
});
}
});
}
如果我添加一個斷點$.ajax({
,並運行調試,這是它停止。如果我然後將鼠標懸停在data
的行success: function(data) {
上,則不會顯示彈出窗口,因此不會顯示任何值。我想看看data
裏面有什麼。
所以我想「也許我需要按F10幾次,所以在顯示值之前,firebug實際上可以運行足夠的javascript/jquery」。所以我做了,我到了該函數的末尾,將鼠標懸停在data
的success: function(data) {
上,並且再次沒有彈出窗口,因此沒有顯示數據。
我在做什麼錯?爲什麼我看不到data
中的內容?
我已經在firefox中安裝了firebug plus firequery。
爲什麼不把斷點放在'success'回調中。甚至只是console.log(數據)應該會顯示結果... – Lix
在成功處理程序中嘗試'console.log(data)'。 –
我會想到,在函數的頂部放置一個斷點將貫穿函數中的所有內容。看起來不合邏輯的是必須在同一個函數的頂部和其他部分放置一個斷點。如果你只是想調試一小部分函數,那麼把斷點放在一個函數中是很有意義的。但我想這將不得不做,即在成功回調中添加一個斷點...... – oshirowanen