search

Home  >  Q&A  >  body text

javascript - Regarding the data called by js, why the source code cannot see the data

Code 1

function get_hot_posts(day)
{
    $('#hot_question_list').html('<p style="padding: 15px 0" align="center"><img src="' + G_STATIC_URL + '/common/loading_b.gif" alt="" /></p>');
    
    $.get(G_BASE_URL + '/explore/ajax/ztlist/sort_type-hot__feature_id-' + FEATURE_ID + '__day-' + day + '__per_page-5', function (response)
    {
        if ($.trim(response) != '')
        {
            $('#hot_question_list').html(response);
        }
        else
        {
            $('#hot_question_list').html('<p style="padding: 15px 0" align="center">' + _t('没有内容') + '</p>');
        }
    });
}

$(document).write(function () {
    $('#feature_dynamic a').click(function ()
    {
        if ($(this).attr('href') == '#unresponsive')
        {
            AWS.load_list_view(G_BASE_URL + '/explore/ajax/ztlist/sort_type-unresponsive__per_page-10__feature_id-' + FEATURE_ID, $('#bp_all_more'), $('#c_all_list'), 1);
        }
        else
        {
            AWS.load_list_view(G_BASE_URL + '/explore/ajax/ztlist/sort_type-new__feature_id-' + FEATURE_ID, $('#bp_all_more'), $('#c_all_list'), 1);
        }
    });

    $('#hot_question_control li.active a').click();
    $('#feature_dynamic li.active a').click();
    
    $.get(G_BASE_URL + '/topic/ajax/question_list/type-best__feature_id-' + FEATURE_ID, function (result) {
        if ($.trim(result) != '')
        {
            $('#c_best_list').html(result);
        }
    });

    AWS.Init.init_comment_box('.aw-add-comment');
});

Code 2

$(document).ready(function () {
    $('#feature_dynamic > a').click(function ()
    {
        $('#feature_dynamic > a').removeClass('cur');

        $(this).addClass('cur');

        if ($(this).attr('rel') == 'unresponsive')
        {
            bp_more_load(G_BASE_URL + '/question/ajax/discuss/sort_type-unresponsive__per_page-10__feature_id-' + FEATURE_ID, $('#bp_all_more'), $('#c_all_list'), 1);
        }
        else
        {
            bp_more_load(G_BASE_URL + '/topic/ajax/question_list/feature_id-' + FEATURE_ID, $('#bp_all_more'), $('#c_all_list'));
        }
    });

    $('#hot_question_control a.cur').click();
    $('#feature_dynamic a.cur').click();
    
    $.get(G_BASE_URL + '/topic/ajax/question_list/type-best__feature_id-' + FEATURE_ID, function (result) {
        if ($.trim(result) != '')
        {
            $('#c_best_list').html(result);
            $('#c_best').show();
        }
    });
});


function get_hot_question(el, day)
{
    $('#hot_question_control a').removeClass('cur');

    el.addClass('cur');

    $('#hot_question_list').html('<p style="padding: 15px 0" align="center"><img src="' + G_STATIC_URL + '/common/loading_b.gif" alt="" /></p>');
    
    $.get(G_BASE_URL + '/question/ajax/discuss/sort_type-hot__feature_id-' + FEATURE_ID + '__day-' + day + '__per_page-5', function (response)
    {
        if ($.trim(response) != '')
        {
            $('#hot_question_list').html(response);
        }
        else
        {
            $('#hot_question_list').html('<p style="padding: 15px 0" align="center">没有内容</p>');
        }
    });
}

What is the difference between these two js codes? Why can’t the data called by code 1 be seen in the source code, while the data called by code 2 can be seen in the source code? Where does the problem occur? It is these two Does the file affect the source code's data? Please tell me how to make code 1 support calling data so that the called data can be seen in the source code

某草草某草草2772 days ago885

reply all(1)I'll reply

  • 学习ing

    学习ing2017-06-13 09:23:47

    $(document).write is js that writes content on the page. What he wrote is not in the script.

    $(document).ready calls the callback function after the dom is loaded. So the code is executed.

    reply
    0
  • Cancelreply