开发者

Limit Ajax mouseover

I would like to know what's the best way to limit ajax call / time.

I'm running the following js function when the user mouseover a table row.

function load()
{
    $.ajax({
          type: "GET",
          url: "process/ajax.php",
          data: "action=action,
          success: function(msg)
                   {
               开发者_开发知识库         if(msg!='')
                        {
                            displayStuff;
                        }

                   }
    });
}

Should I create a timestamp and compare it with the previous one?, How can I do that in a global context.


As a suggestion, why not use the now-famous hoverIntent plugin to prevent the accidental firing of ajax calls on the mouseover event.


You can use the javascript Date Object to store the last update time, and check (against a new call to the Date Object) that upon future mouseovers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜