0
以下是我的ajax調用代碼。php代碼點火器ajax調用甜蜜警報
var date = new Date();
yr = date.getFullYear(),
month = +date.getMonth() + 1 < 10 ? '0' + parseInt(date.getMonth() + 1) : date.getMonth() + 1,
day = +date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
newDate = yr + '-' + month + '-' + day;
$("#dateupdated").val(newDate);
var url = "<?php echo base_url("resident/updateresident/{$resident->id }"); ?>"
$.ajax({
url: url,
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function (data) {
swal("Operation completed successfully.");
// var objs = $.parseJSON(data);
// var status=objs.status;
}
});
它工作正常,但當我用甜蜜的警報確認彈出窗口時,它不會將數據發佈到控制器。有人可以告訴我如何擺脫這個?
新的代碼是:
swal({
title: "Are you sure?",
text: "Are you sure that you want to cancel this order?",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
confirmButtonText: "Yes, cancel it!",
confirmButtonColor: "#ec6c62"
}, function() {
alert();
var date = new Date();
yr = date.getFullYear(),
month = +date.getMonth() + 1 < 10 ? '0' + parseInt(date.getMonth() + 1) : date.getMonth() + 1,
day = +date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
newDate = yr + '-' + month + '-' + day;
$("#dateupdated").val(newDate);
var url = "<?php echo base_url("resident/updateresident/{$resident->id }"); ?>"
$.ajax({
url: url,
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function (data) {
swal("Operation completed successfully.");
// var objs = $.parseJSON(data);
// var status=objs.status;
}
});
});
請正確格式化您的代碼 –