jQuery的ajaxStart不工作 [英] jquery ajaxStart not working

查看:163
本文介绍了jQuery的ajaxStart不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您在点击点击这里这里订购按钮: HTTP://www.game ong​​love.com/高格/ test3.html,然后点击lightboxed窗口弹出相同的按钮,一个Ajax请求将运行使用$。员额()。

If you click on the click here to order button here: http://www.game onglove.com/ gog/ test3.html, and then click the same button on the lightboxed window that pops up, an ajax request will run using $.post().

您可以点击继续购物返回到previous lightboxed窗口,迅速启动了。

You can hit "continue shopping" to return to the previous lightboxed window to quickly start over.

如果我在控制台(Chrome或Firefox)在本地执行的jQuery的code,然后它工作正常。它只是不会从那里源$ C ​​$ C工作:

If I execute the jquery code here in the console (chrome or firefox), then it works properly. It just won't work from where it is in the source code:

$('#cboxLoadingGraphic').ajaxStart(function() {
$(this).show();
$('#cboxLoadedContent').hide();
}).ajaxStop(function() {
$(this).hide();
$('#cboxLoadedContent').fadeIn('slow');
});

为什么将它从控制台工作,但是不能在源在其当前位置?我如何得到这个工作?

Why will it work from the console, but not in its current location in the source? How do I get this to work?

推荐答案

该元素的入门后创建的,你有它的创建后绑定,或者简单一点只是绑定处理程序文件从一开始:

That element's getting created later, you have to bind after it's created, or a bit simpler just bind the handler to document from the start:

$(document).ajaxStart(function() {
  $('#cboxLoadingGraphic').show();
  $('#cboxLoadedContent').hide();
}).ajaxStop(function() {
  $('#cboxLoadingGraphic').hide();
  $('#cboxLoadedContent').fadeIn('slow');
});

这篇关于jQuery的ajaxStart不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆