js 延遲幾秒重新整理或轉跳
阿新 • • 發佈:2018-12-14
setTiuimeout(function(){
self.location='{:url('course',['pid'=>$pid,'cid'=>$cid])}';
},1000);
例子:
//建立直播 $(document).on("click",".play",function(){ var arrid = $(this).attr("lay-id"); var strs= new Array(); //定義一陣列 strs=arrid.split("|"); //字元分割 pid= strs[0]; cid= strs[1]; bid= strs[2]; cc_id= strs[3]; $.ajax({ url:'{:url('course_del')}', type:"post", data:{pid:pid,cid:cid,bid:bid,ccid:ccid,action:'addlive'}, async:true, success:function(data){ if(data[0]==1){ layer.msg(data[1]); setTiuimeout(function(){ self.location='{:url('course',['pid'=>$pid,'cid'=>$cid])}'; },1000); }else{ layer.msg(data[1]); //table.render({});//重新渲染 } }, error:function(){ layer.msg('失敗!'); } }); });