开发者社区> 问答> 正文

请教一个jquery 中getjson问题

function list(_path,record) {
    $.getJSON(getFileUrl('lt', _path), function(data) { //这里传入 / 根目录给getfileurl函数
        dirs = data.dirs;
        files = data.files;
        if(!record) {
            if(path != data.path) {
                listhistory.push(path);
            }
        }
        path = data.path;
        updatePath();
        updateList();
    });
}
------------------------------------------------------------------
//getfileurl接收2个参数 lt 和 / 根目录 ,file是空的 
function getFileUrl(type, _path, file) {
 
    if(file) {
        file = '&file='+encodeURIComponent(file);
    } else {
        file = '';
 
    }
    return 'index.php?action='+type+'&path='+encodeURIComponent(_path)+file;
 
}

按理来说, 该函数应该返回 index.php?action=lt&path=%2F

但是我在浏览器调试工具中看到它在后面自动产生了一个随机数,是用于解决浏览器缓存问题的。但是我在代码中找不到任何一句能够产生该随机数的代码块。请问是不是getjson会自动添加随机数解决浏览器缓存问题?

http://localhost:63342/proj/index.php?action=lt&path=%2F&_=1407240310747 (后面红字部分是自动生成的吗? )

展开
收起
a123456678 2016-07-12 14:24:35 1786 0
1 条回答
写回答
取消 提交回答
  • $.getJSON 没法指定 cache 参数,调用 $.ajax并设置 dataType 为 jsonp 就是 getJSON,这时就可以设置 cache 参数了

    2019-07-17 19:54:53
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
Javascript中的对象 立即下载
Javascript中的函数 立即下载
JavaScript函数 立即下载