错误:
$.when(.).then(.).finally不是函数
我的代码:
$.when($.ajax( "/page1.php" ), $.ajax( "/page2.php" )).then(function () {
swal('success')
}).finally(function () {
// Reset form elements
});我想在这两个API调用完成后重置我的表单。
发布于 2022-04-22 07:43:12
我找到解决办法了。$.when还没有最终的方法。
参考链接:https://api.jquery.com/jquery.when/
它有两个回调参数。就像下面,
$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) )
.then( myFunc, myFailure );所以我的代码如下所示。
$.when($.ajax("/page1.php"), $.ajax("/page2.php")).then(function () {
swal('success');
// Reset form elements
}, function () {
// Reset form elements
});https://stackoverflow.com/questions/71925414
复制相似问题