举一个简单的例子,我可以向您展示我如何在自己的网站上进行操作。我将Ajax呼叫放入了甜蜜警报中。
function deleteorder(orderid) { swal({ title: "Are you sure?",text: "Are you sure that you want to cancel this order?",type: "warning", showCancelButton: true, closeOn/confirm/i: false, /confirm/iButtonText: "Yes, cancel it!", /confirm/iButtonColor: "#ec6c62" }, function() { $.ajax( { type: "post", url: "/admin/delete_order.php", data: "orderid="+orderid, success: function(data){ } } ) .done(function(data) { swal("Canceled!", "Your order was successfully canceled!", "success"); $('#orders-history').load(document.URL + ' #orders-history'); }) .error(function(data) { swal("Oops", "We couldn't connect to the server!", "error"); }); }); }因此,只有在您按下确认按钮时才能进行ajax调用。我希望这可以帮助您按照需要的方式排列代码。



