当前位置 : 主页 > 编程语言 > c++ >

给定时器所调用的函数设置传参,改变setInterval

来源:互联网 收集:自由互联 发布时间:2021-07-03
gistfile1.txt var tname;var temp = 0;function obtain(photoid,addaction){//alert(addaction)if(temp == 0){temp = 1;var photoStyle=document.getElementById(photoid);$.ajax({url:addaction,type:"post",async:false,success:function(data){if(data==0
gistfile1.txt
var tname;
var temp = 0;
function obtain(photoid,addaction){
	//alert(addaction)
	if(temp == 0){
		temp = 1;
		var photoStyle=document.getElementById(photoid);
		$.ajax({
				url:addaction,
				type:"post",
				async:false,
				success:function(data){
					if(data==0){
						photoStyle.style.display="none";
						window.clearInterval(tname);
					}
					temp = 0;
				}
			});
		}
}   

function loadGif(photoid,addaction)
{

    //设置定时器所调用函数的参数
   var mySetInterval = setInterval; 
    window.setInterval = function(callback, interval) 
    { 
          var args = Array.prototype.slice.call(arguments, 2); 
          function callFn(){callback.apply(null, args);} 
          return mySetInterval(callFn, interval); 
    } 
    //设置图片的的属性(隐藏/显示)
    document.getElementById(photoid).style.display="block";

	tname=window.setInterval(obtain,500,photoid,addaction);
	
}
网友评论