ajax 有事件完成后事件吗,点击事件后,jquery等待ajax加载完成

我正在使用ajax分层导航的magento网站上工作。当用户单击分层导航中的颜色链接时,它会加载相关产品的列表。我想在ajax完成后触发click事件。

我认为我可以使用jQuery when()功能,但我无法正常使用。

jQuery( "a#red-hoi-swatch" ).click(function() {

jQuery.when( jQuery.ajax() ).then(function() {

jQuery("a[name*='chili-ireye']").click();

});

});

基本上,我希望在用户点击jQuery("a[name*='chili-ireye']").click();后完成ajax后运行a#red-hoi-swatch。

更新

我找到了ajax对此负责,它来自我们购买的Magento Blacknwhite主题

/*DONOT EDIT THIS CODE*/

function sliderAjax(url) {

if (!active) {

active = true;

jQuery(function($) {

oldUrl = url;

$('#resultLoading .bg').height('100%');

$('#resultLoading').fadeIn(300);

try {

$('body').css('cursor', 'wait');

$.ajax({

url: url,

dataType: 'json',

type: 'post',

data: data,

success: function(data) {

callback();

if (data.viewpanel) {

if ($('.block-layered-nav')) {

$('.block-layered-nav').after('

$('.ajax-replace').after(data.viewpanel).remove();

}

}

if (data.productlist) {

$('.category-products').after('

$('.ajax-category-replace').after(data.productlist).remove();

}

var hist = url.split('?');

if(window.history && window.history.pushState){

window.history.pushState('GET', data.title, url);

}

$('body').find('.toolbar select').removeAttr('onchange');

$('#resultLoading .bg').height('100%');

$('#resultLoading').fadeOut(300);

$('body').css('cursor', 'default');

ajaxtoolbar.onReady();

jQuery('.block-layered-nav a').off('click.vs');

try{

ConfigurableSwatchesList.init();

}catch(err){}

}

})

} catch (e) {}

});

active = false

}

return false

}

function callback(){

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值