$(this)在ajax中无效的解决方案


在ajax方法里写$(this)指向的是最近调用它的jquery对象,所以这里的$(this)指的是ajax对象,而不是$(".enter_caozuo").find(".gd"),要想解决这个问题,就需考虑增加一个中间变量传递这个对象,示例:
$(".enter_caozuo").find(".gd").click(function(){
var mythis = $(this);

$.ajax({
type:"GET",
url:"lanEdit.php?lanname="+lan_name,
success:function(msg){
var info = eval('('+msg+')');
var state = info.state;
mythis.parents(".yuan").siblings(".more").find(".lanname").val(info.name);
//....你的代码

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM