javascript - Mengenai data yang dipanggil oleh js, mengapa kod sumber tidak dapat melihat data
某草草
某草草 2017-06-13 09:21:47
0
1
795

Kod 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');
});

Kod 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>');
        }
    });
}

Apakah perbezaan antara kedua-dua kod js ini Mengapa data yang dipanggil oleh kod 1 tidak boleh dilihat dalam kod sumber, manakala data yang dipanggil oleh kod 2 boleh dilihat dalam kod sumber? adakah pengaruh kedua-dua fail ini data kod sumber? Tolong beritahu saya cara membuat kod 1 menyokong data panggilan supaya data yang dipanggil boleh dilihat dalam kod sumber

某草草
某草草

membalas semua(1)
学习ing

$(document).write ialah js yang menulis kandungan pada halaman. Apa yang dia tulis tiada dalam skrip.

$(dokumen). sedia memanggil fungsi panggil balik selepas dom dimuatkan. Jadi kod itu dilaksanakan.

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!