简体   繁体   English

firebug javascript / jquery调试

[英]firebug javascript/jquery debugging

I have the following script which I want to debug: 我有以下要调试的脚本:

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() );
                });
            });
        }
    });
}

If I add a breakpoint to $.ajax({ , and run the debugging, that is where it stops. If I then hover over data in the line success: function( data ) { , no popup is displayed so no value can be seen. I want to see what is inside data . 如果我在$.ajax({添加一个断点,然后运行调试,它将在此停止。如果然后我将鼠标悬停在success: function( data ) {行中的datasuccess: function( data ) { ,则不会显示任何弹出窗口,因此看不到任何值我想看看里面的data是什么。

So I thought "maybe I need to press F10 a couple of times so firebug can actually run enough of the javascript/jquery before a value is displayed". 因此,我认为“也许我需要按几次F10键,以便Firebug在显示值之前实际上可以运行足够的javascript / jquery”。 So I did, I got to the end of the function, hovered the mouse over data in success: function( data ) { , and again, no popup, therefore no data is displayed. 所以我做到了,我到了函数的结尾, success: function( data ) {将鼠标悬停在datasuccess: function( data ) { ,同样,没有弹出窗口,因此没有数据显示。

What am I doing wrong? 我究竟做错了什么? Why can't I see what is held within data ? 为什么看不到data

I have installed firebug plus firequery in firefox. 我已经在firefox中安装了firebug和firequery。

data is defined as a parameter of your success callback function. data定义为成功回调函数的参数。 If you want to see it's value, you have to be on a line in the implementation of this function. 如果要查看它的价值,则必须在执行此功能时保持一致。

You should put the breakpoint on the first line of your success callback, which is 您应该将断点放在成功回调的第一行,即

$( "#divTabsDropdown" ).empty();

If it's never hit, it's that you request is still pending or ended up in an error. 如果它从未被命中过,那就是您的请求仍处于待处理状态或最终导致错误。 In this last case, error callback will be called. 在这最后一种情况下,将调用错误回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM