如何将原型“Ajax.Responders.register”翻译为jQuery

时间:2013-12-17 08:36:04

标签: javascript jquery ajax prototypejs

我必须将一些原型代码翻译成jquery,而且我不知道如何翻译这部分:

Ajax.Responders.register({
  onCreate: function() {
    $('working').show();
    window.onbeforeunload = check_working;
  },
  onComplete: function() {
    $('working').hide();
    window.onbeforeunload = null;
  }
});

事实上我找到了一些处理这个问题的页面(例如Prototype - Are there AJAX start/stop events to global trigger an AJAX modal wait message?),但我这样做了:

jQuery(document).ajaxSend(function() {
  jQuery('#working').show();
  window.onbeforeunload = check_working;
});
jQuery(document).ajaxStop(function() {
  jQuery('#working').hide();
  window.onbeforeunload = null;
});

我不知道为什么,但我从未进入ajax.start并停止(我尝试使用console.log做同样的事情,我使用以前的版本工作)。我没有错误。

你有任何想法如何解决它?

提前谢谢。

0 个答案:

没有答案