有人告诉我,success:function()
它已被弃用,应.done()
改为使用。但是,我不知道如何在我的ajax代码中正确替换它。我敢肯定这是一个简单的解决方法。
您能告诉我这段代码是什么样吗?谢谢
$.ajax({
type: "POST",
url: "confirm.php",
dataType:"text",
data: {name: $('#name').val(), submitter: 'yes' },
success: function(data)
{
$("#mainForm").hide();
$('#thankYou').show();
}
})
不建议使用该success
属性,因此无需更改代码。这是一种误解,是因为不赞成使用该方法。jqXHR.success
无论如何,这就是您将使用该done
方法的方式:
$.ajax({
type: "POST",
url: "confirm.php",
dataType:"text",
data: {name: $('#name').val(), submitter: 'yes' }
}).done(function(data) {
$("#mainForm").hide();
$('#thankYou').show();
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句