0
以下は私のajaxコールコードです。php codeイグナイター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;
}
});
});
あなたのコードを正しくフォーマットしてください –