function SwalPopup(ip, method) { var methodmsg = method.charAt(0).toUpperCase() + method.slice(1); swal.fire({ text: 'Are you sure you want to '+methodmsg+' ?', type: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", confirmButtonText: 'Yes, '+methodmsg+'!', cancelButtonColor: '#d33', showCloseButton: true, showLoaderOnConfirm: true, preConfirm: function () { return new Promise(function (resolve, reject) { var ajaxCall = $.ajax({ url: 'wait.php', type: 'GET', dataType: 'json', timeout: 5000 }) ajaxCall.done(function( response ){ resolve(response); swal.fire({ type: 'success', html: 'Component with IP: <?php echo $action_ip; ?>'+ip+' was '+methodmsg+' sucessfully!', showCancelButton: false, confirmButtonColor: '#3085d6', confirmButtonText: 'Ok', allowOutsideClick: false }); });我的wait.php文件正在执行sleep(10)并返回true:sleep(10);echo json_encode(array( 'success' => true,));因此,通过Ajax调用的wait.php文件需要10秒钟,但是我对ajax请求强制设置了5秒钟的超时。在超时完成之前,swealert弹出窗口会显示一个加载动画和“取消”按钮。但是此取消按钮不可单击。我想给它分配一个异常中止的功能,以便如果花费很长时间,可以取消ajax请求。这是一个错误吗?
添加回答
举报
0/150
提交
取消