jquery ajax获得返回值以后再修改div里的值,怎么改不了

$(document).ready(function(){

$("button").click(function(){
aa=$(this).prev("#rad").val();
$.post("http_creat.php",{jj:aa},function(result){
if (result) {
alert(result);
$(this).next("#dinggou").html("已订购");
}
});

});
});

这样怎么修改不了

$.ajax({
url:"",
dataType:'text',
success:function(data){
//你返回的data内容为:123456
$("#div1").html(data); //这样就可以修改你的div内容,将aaaa改成了123456
}
})
//比如你有一个div
<div id="div1">aaaa</div>
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-05-25
$(this).next("#dinggou").html("已订购");

换成 $("button").next("#dinggou").html("已订购"); 试试
第2个回答  推荐于2018-03-01
$(document).ready(function () {
$("button").click(function () {
var currentButton=$(this);
aa = currentButton.prev("#rad").val();
$.post("http_creat.php", {
jj: aa
}, function (result) {
if (result) {
alert(result);
currentButton.next("#dinggou").html("已订购");
}
});
});
});本回答被提问者和网友采纳
第3个回答  2013-05-25
this要慎用啊,很容易就对象转移了。
相似回答