ajax执行时函数,ajax调用后执行jQuery函数时发生的问题

我试图在执行我的Ajax调用后隐藏了input的父项,但由于某种原因它没有工作,没有发生效果,父项也未隐藏。ajax调用后执行jQuery函数时发生的问题

这里是我的JQuery的片断:

$(".getqty").mouseover(function() {

var split = this.id.split(":");

var color = split[0];

var size = split[1];

var prodID = split[2];

$.ajax({ //create an ajax request to loadstuff.php

type: 'POST',

url: 'includes/loadstuff.php',

dataType: 'html', //expect html to be returned

data:'color='+color+'&size='+size+'&prodID='+prodID,

success: function(response){

$(this).parent().hide(); //Problematic part

},

error:function (xhr, ajaxOptions, thrownError){

alert(thrownError);

}

});

});

这是我的HTML:

我试图做的也许显得毫无意义,但它实际上是我试图理解为什么隐藏父项在悬停时不起作用。

但是我尝试了以下并在ajax调用之前隐藏了父项并且它工作正常。我不明白为什么。

$(".getqty").mouseover(function() {

var split = this.id.split(":");

var color = split[0];

var size = split[1];

var prodID = split[2];

$(this).parent().hide(); //Moved it here and it works. But I need it after the ajax call

$.ajax({ //create an ajax request to loadstuff.php

type: 'POST',

url: 'includes/loadstuff.php',

dataType: 'html', //expect html to be returned

data:'color='+color+'&size='+size+'&prodID='+prodID,

success: function(response){

},

error:function (xhr, ajaxOptions, thrownError){

alert(thrownError);

}

});

});

2015-12-20

nTuply

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值