bootbox后如何使用php代码确认提醒
问题描述:
我想在用户确认后执行一些php代码。我的意思是如果用户点击是的一些PHP函数应该执行。我该怎么做?bootbox后如何使用php代码确认提醒
bootbox.confirm({
message: "This is a confirm with custom button text and color! Do you like it?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (result) {
console.log('This was logged in the callback: ' + result);
}
});
答
正如Ad5001 Gameur codeur autre所述,您有请求。这里有一个例子:用户点击是
<script type="text/javascript">
function loadXMLDoc() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
if (xmlhttp.status == 200) {
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
else if (xmlhttp.status == 400) {
alert('There was an error 400');
}
else {
alert('something else other than 200 was returned');
}
}
};
xmlhttp.open("GET", "ajax_info.txt", true);
xmlhttp.send();
}
</script>
后,调用函数(在这种情况下,所谓的loadXMLDoc()
)。
不要忘记用您的PhP文件替换ajax_info.txt
。
在回调函数中,您将向运行代码的PHP页面发出AJAX请求。 – David
已经有回拨块了;你可以使用alert来检查按钮的值:'callback:function(result){alert(result);}' – bharat
在回调函数中,我该如何编写php代码? – rivas