javascript - 关于js调用的数据,为什么源代码看不到数据
某草草
某草草 2017-06-13 09:21:47
0
1
794

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

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

这两个js代码的区别是什么,为什么代码1调用的数据在源代码里面看不到,而代码2调用的数据可以在源代码里面看到,问题出现在哪里,是这两个文件影响源代码的数据吗?求解,怎么让代码1支持调用的时候可以在源代码里面看到调用的数据

某草草
某草草

全部回复(1)
学习ing

$(document).write是js把内容写在页面上。他写出来的内容并没有在script里面。

$(document).ready是在dom加载完了之后,调用回调函数。所以代码执行了。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!