只是想知道是否有一种方法可以在 PHP else die 语句的事件中包含一个 JQuery 模式框/弹出窗口,例如:else die("Invalid");
.
因此,else die 不会触发页面上显示的输出,而是Invalid
触发包含 output 的 JQuery 模式弹出框Invalid
。
您可以通过简单地跟踪 php 的成功输出来完成
<?php
if($logged) {
echo "success";
} else {
die("Sorry incorrect login information");
}
?>
你可以用jquery跟踪它
$(#form).on("submit",function() {
var inputs = $(this).serialize();
var ulr = $(this).attr("action");
$.post(url, inputs, function(data) {
if(data !="success") {
//display UI dialog or alert with data
} else {
//proceed
}
});
});
First better use exit() not die :) it's the standard.
You can write
else { exit("<script>alert('s');</script>"); }
Inside it you can write in your script. It will run! But if you want jquery you must be sure that it has been loaded before this exit line. After it nothing more will be send to user browser.