在PHP中回显jQuery警报弹出窗口
问题描述:
我想在满足PHP中的某些条件时显示一个弹出警报框.像这样:
I want to display a pop-up alert box upon some condition in PHP being satisfied. Something like:
echo "<script type="text/javascript"> alert('bleh'); </script>";
使用自定义jquery警报框除外.这可能吗?
except using a custom jquery alert box. Is this possible??
我尝试过类似的事情:
echo "<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>";
但是它给了我一个怪异的效果.没有弹出.
but it gives me a weird effect. Not pop up.
感谢您的关注.
答
echo <<<EOD
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$("#dialog-message").dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
</script>
EOD;