$(document).ready(function (){
var names = new Array();
names[0] = 'jimit';
names[1] = 'vinod';
names[2] = 'vineet';
for( var x in names){
console.log(names[x]);
}
window.reLoad();
});
在上面的代码中,我想等到执行完毕然后调用window.reLoad();
由于
修改
上面的代码是ajax请求的回调函数,这会产生差异吗?
答案 0 :(得分:1)
$(function (){
var names = new Array();
names[0] = 'jimit';
names[1] = 'vinod';
names[2] = 'vineet';
for( var x in names){
console.log(names[x]);
}
window.location = location.href;
})
OR
$(function (){
var names = new Array();
names[0] = 'jimit';
names[1] = 'vinod';
names[2] = 'vineet';
for( var x in names){
console.log(names[x]);
}
setTimeout( reloadWindow, 2000 );
})
function reloadWindow(){
window.location = location.href;
}