jQuery mouseleave ajax请求

I was wondering if it is possible for an ajax request to be triggered from a mouseleave function? I would like the string 'Y' to be sent on when the mouse leaves the li so it can be updated in the database.

is this possible by any chance?

(function(){
  $('li#myId').mouseenter(function(){
    var y = 'Y';
  }).mouseleave(function(){

    $.ajax({
      type: 'POST',
      url: 'update.php',
      data: 'y='+y,
      success: function(response){
        $('li.#myId').html(response);
      }

    });
  });

})();

查看全部
weixin_33739523
weixin_33739523
2012/04/11 09:35
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

2个回复