function updatecache(){ $.ajax({ type: 'get', url: '/home/index/updatecache', timeout: 5000, data: {id: bookid, hash: hash}, dataType: 'json', success: function(data){ if(data.status == 'error'){ layer.msg('宸叉槸鏈€鏂扮珷鑺傦紝鏆傛棤鏇存柊锛?); } $('#loadingtip').html('锛堟彁绀猴細鏈€鏂扮珷鑺傛姄鍙栨垚鍔燂紒锛?); if(data.status == 'success'){ layer.msg('鏈€鏂扮珷鑺傛姄鍙栨垚鍔燂紒'); var newlisthtml=listhtml=''; var chapterhtml = $('#chapterhtml').html(); $.each(data.content, function(i, item){ if(item.title){ listhtml = chapterhtml.replace('{}', ''); listhtml = listhtml.replace('{subid}', Math.floor(item.id/1000)); listhtml = listhtml.replace('{id}', parseInt(item.id) + parseInt(index_rule)); listhtml = listhtml.replace('{cid}', parseInt(item.cid) + parseInt(cindex_rule)); listhtml = listhtml.replace('{dir}', item.cate); listhtml = listhtml.replace('{title}', item.title); newlisthtml += listhtml; } }); $('#newchapter').html(newlisthtml); } }, complete : function(xhr,status){ if(status == 'timeout'){ $('#loadingtip').html('锛堟彁绀猴細鎶撳彇瓒呮椂锛岀綉缁滅箒蹇欙紝璇峰埛鏂板悗閲嶈瘯锛侊級'); layer.msg('鎶撳彇瓒呮椂锛岀綉缁滅箒蹇欙紝璇风◢鍚庨噸璇曪紒'); } } }); } $(function() { if(typeof(bookid) != "undefined"){ setTimeout(updatecache, 2000); } });