Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery设置了一些关于它的问题_Javascript_Jquery - Fatal编程技术网

Javascript jquery设置了一些关于它的问题

Javascript jquery设置了一些关于它的问题,javascript,jquery,Javascript,Jquery,我有一个带有标签系统的网站,就像在stackoverflow上工作的那个种系统。 我的问题是: $("#area1 ul li").hover(function(){ var width= $(this).offset(); $(".flyout").css({"top":width.top+19,"left":width.left}); $(".flyout").toggle(); setTimeout(function(

我有一个带有标签系统的网站,就像在stackoverflow上工作的那个种系统。 我的问题是:

    $("#area1 ul li").hover(function(){
        var width= $(this).offset();
        $(".flyout").css({"top":width.top+19,"left":width.left});
        $(".flyout").toggle();
        setTimeout(function() {
          $.ajax({ 
            url: web + "sources/queans/sql.php", type: "POST",
            data: { 
               action: "taginfo",
               tag: $(this).text(),
               token: t, 
               ajax: "1" 
            },
            success: function (output) {
              $(".flyout").html(output);
            }
          });
        }, 2000);
     $(".flyout").html('<center><img style="margin-top:20px;"  src="http://www.cloudynights.com/public/style_images/master/ajax_loading.gif" /> </center>');
   });
$(“#区域1 ul li”)。悬停(函数(){
变量宽度=$(this.offset();
$(“.flyout”).css({“top”:width.top+19,“left”:width.left});
$(“.flyout”).toggle();
setTimeout(函数(){
$.ajax({
url:web+“sources/queans/sql.php”,键入:“POST”,
数据:{
行动:“taginfo”,
标记:$(this).text(),
令牌:t,
阿贾克斯:“1”
},
成功:功能(输出){
$(“.flyout”).html(输出);
}
});
}, 2000);
$(“.flyout”).html(“”);
});
  • 执行此Jquery脚本需要在鼠标悬停时等待2秒 元素
  • 如果用户将鼠标悬停在元素上,则仍将执行查询 运行并执行代码?如果没有,我怎样才能停止之前的代码 它需要从sql.php文件中获取数据吗
  • 当鼠标悬停在元素上时,这个Jquery脚本是否需要等待2秒

    不完全是这样,一旦用户将鼠标悬停在元素上,计时器就会启动,2秒后执行操作。用户不必一直悬停在元素上,就可以实现这一点

    如果用户移除鼠标悬停元素,查询是否仍将运行并执行代码

    如上所述,该操作将在首次悬停元素2秒后执行,而不管用户此后做了什么

    如果没有,我如何在代码需要来自sql.php文件数据之前停止代码

    将调用
    setTimeout
    的结果捕获到变量中(通常称为
    timerId
    或类似),并在用户停止悬停元素时调用
    clearTimeout(timerId)

    /* two variables outside hover scope to 
       hold reference to setTimeout & Ajax call*/
    var timer, ajaxRequest;
    $("#area1 ul li").hover(function(){
            var width= $(this).offset();
            $(".flyout").css({"top":width.top+19,"left":width.left});
            $(".flyout").toggle();
           timer = setTimeout(function() {
             ajaxRequest = $.ajax({ 
                url: web + "sources/queans/sql.php", type: "POST",
                data: { 
                   action: "taginfo",
                   tag: $(this).text(),
                   token: t, 
                   ajax: "1" 
                },
                success: function (output) {
                  $(".flyout").html(output);
                }
              });
            }, 2000);
         $(".flyout").html('<center><img style="margin-top:20px;"  src="http://www.cloudynights.com/public/style_images/master/ajax_loading.gif" /> </center>');
       }, 
      function(){
        // second callback to handle mouseleave
        if(typeof ajaxRequest !== 'undefined'){
            // abort the ongoing Ajax call
            ajaxRequest.abort();
        }else if(typeof timer !== 'undefined'){
           // timeout callback is not invoked yet, so clear it
           clearTimeout(timer);
        }
       // show some message in flyout or close the popup directly
      });
    
    请参阅下面的简化演示

    var-timerId;
    $('.container').hover(函数(){
    $('.message').text('悬停已启动,背景将在5秒内更改。鼠标悬停可取消');
    var$this=$(this);
    timerId=setTimeout(函数(){
    $this.css('background-color','red');
    },5000);
    },
    函数(){
    清除超时(timerId);
    $('.message').text('操作已取消');
    });
    
    .container{
    宽度:300px;
    高度:300px;
    边框:1px纯黑
    }
    
    在我上空盘旋
    
    当鼠标悬停在元素上时,这个Jquery脚本是否需要等待2秒

    不完全是这样,一旦用户将鼠标悬停在元素上,计时器就会启动,2秒后执行操作。用户不必一直悬停在元素上,就可以实现这一点

    如果用户移除鼠标悬停元素,查询是否仍将运行并执行代码

    如上所述,该操作将在首次悬停元素2秒后执行,而不管用户此后做了什么

    如果没有,我如何在代码需要来自sql.php文件数据之前停止代码

    将调用
    setTimeout
    的结果捕获到变量中(通常称为
    timerId
    或类似),并在用户停止悬停元素时调用
    clearTimeout(timerId)

    /* two variables outside hover scope to 
       hold reference to setTimeout & Ajax call*/
    var timer, ajaxRequest;
    $("#area1 ul li").hover(function(){
            var width= $(this).offset();
            $(".flyout").css({"top":width.top+19,"left":width.left});
            $(".flyout").toggle();
           timer = setTimeout(function() {
             ajaxRequest = $.ajax({ 
                url: web + "sources/queans/sql.php", type: "POST",
                data: { 
                   action: "taginfo",
                   tag: $(this).text(),
                   token: t, 
                   ajax: "1" 
                },
                success: function (output) {
                  $(".flyout").html(output);
                }
              });
            }, 2000);
         $(".flyout").html('<center><img style="margin-top:20px;"  src="http://www.cloudynights.com/public/style_images/master/ajax_loading.gif" /> </center>');
       }, 
      function(){
        // second callback to handle mouseleave
        if(typeof ajaxRequest !== 'undefined'){
            // abort the ongoing Ajax call
            ajaxRequest.abort();
        }else if(typeof timer !== 'undefined'){
           // timeout callback is not invoked yet, so clear it
           clearTimeout(timer);
        }
       // show some message in flyout or close the popup directly
      });
    
    请参阅下面的简化演示

    var-timerId;
    $('.container').hover(函数(){
    $('.message').text('悬停已启动,背景将在5秒内更改。鼠标悬停可取消');
    var$this=$(this);
    timerId=setTimeout(函数(){
    $this.css('background-color','red');
    },5000);
    },
    函数(){
    清除超时(timerId);
    $('.message').text('操作已取消');
    });
    
    .container{
    宽度:300px;
    高度:300px;
    边框:1px纯黑
    }
    
    在我上空盘旋
    
    当鼠标悬停在元素上时,这个Jquery脚本是否需要等待2秒

    不完全是这样,一旦用户将鼠标悬停在元素上,计时器就会启动,2秒后执行操作。用户不必一直悬停在元素上,就可以实现这一点

    如果用户移除鼠标悬停元素,查询是否仍将运行并执行代码

    如上所述,该操作将在首次悬停元素2秒后执行,而不管用户此后做了什么

    如果没有,我如何在代码需要来自sql.php文件数据之前停止代码

    将调用
    setTimeout
    的结果捕获到变量中(通常称为
    timerId
    或类似),并在用户停止悬停元素时调用
    clearTimeout(timerId)

    /* two variables outside hover scope to 
       hold reference to setTimeout & Ajax call*/
    var timer, ajaxRequest;
    $("#area1 ul li").hover(function(){
            var width= $(this).offset();
            $(".flyout").css({"top":width.top+19,"left":width.left});
            $(".flyout").toggle();
           timer = setTimeout(function() {
             ajaxRequest = $.ajax({ 
                url: web + "sources/queans/sql.php", type: "POST",
                data: { 
                   action: "taginfo",
                   tag: $(this).text(),
                   token: t, 
                   ajax: "1" 
                },
                success: function (output) {
                  $(".flyout").html(output);
                }
              });
            }, 2000);
         $(".flyout").html('<center><img style="margin-top:20px;"  src="http://www.cloudynights.com/public/style_images/master/ajax_loading.gif" /> </center>');
       }, 
      function(){
        // second callback to handle mouseleave
        if(typeof ajaxRequest !== 'undefined'){
            // abort the ongoing Ajax call
            ajaxRequest.abort();
        }else if(typeof timer !== 'undefined'){
           // timeout callback is not invoked yet, so clear it
           clearTimeout(timer);
        }
       // show some message in flyout or close the popup directly
      });
    
    请参阅下面的简化演示

    var-timerId;
    $('.container').hover(函数(){
    $('.message').text('悬停已启动,背景将在5秒内更改。鼠标悬停可取消');
    var$this=$(this);
    timerId=setTimeout(函数(){
    $this.css('background-color','red');
    },5000);
    },
    函数(){
    清除超时(timerId);
    $('.message').text('操作已取消');
    });
    
    .container{
    宽度:300px;
    高度:300px;
    边框:1px纯黑
    }
    
    在我上空盘旋
    
    当鼠标悬停在元素上时,这个Jquery脚本是否需要等待2秒

    不完全是这样,一旦用户将鼠标悬停在元素上,计时器就会启动,2秒后执行操作。用户不必一直悬停在元素上,就可以实现这一点

    如果用户移除鼠标悬停元素,查询是否仍将运行并执行代码

    如上所述,该操作将在首次悬停元素2秒后执行,而不管用户此后做了什么

    如果没有,我如何在代码需要来自sql.php文件数据之前停止代码

    将调用
    setTimeout
    的结果捕获到变量中(通常称为
    timerId
    或类似),并在