1
我想通過JS發送一個表單,而不需要HTML,我有一個用戶信息表,並且有按鈕被自動添加使用JS,而我無法將該信息傳遞給HTML(JS表覆蓋刪除所有表單的HTML表),那麼我可以使用JS提交查詢到PHP嗎?直接從JS(無HTML)提交PHP表單
這是當我點擊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