JSを使用してフォームを送信しようとしていますが、HTMLを必要とせずに、ユーザー情報付きのテーブルがあり、JSを使用して自動的にボタンが追加されていますその情報をHTMLに渡すことはできません(JSテーブルはすべてのフォームを削除するHTMLテーブルを上書きします).JSのみを使用してPHPにクエリを送信する方法はありますか?JSから直接PHPフォームを送信する(HTMLなし)
この関数は(SwaIでの「を」部分では(私は)甘いアラート推測している)、警告が出力されている場合は、私はJSが
function banAccount(id, username){
swal({
title: "Do you really want to ban "+username+"?",
text: "Enter amount of days, -1 equals to permanent ban.",
input: 'number',
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
showLoaderOnConfirm: true,
preConfirm: function (duration) {
return new Promise(function (resolve, reject) {
setTimeout(function() {
if (duration === '0') {
reject('Please type -1 for permanent ban or a number greater than 1!')
} else {
resolve()
}
}, 2000)
})
},
allowOutsideClick: false
}).then(function(duration){
action_id = id;
action_type = "ban";
action_params = duration;
alert("id:"+action_id+", type:"+action_type+", params:"+action_params)
// Here's where I need to send "action_id", "action_type" and "action_params" to PHP
});
}
あなたは、Ajaxをタグ付けしていますが、それに精通していますか? Ajaxはあなたが必要とするものです – GrumpyCrouton