从php重定向错误打开jquery对话框
我在数据库更新后从重定向打开jquery窗口时遇到问题。当页面重定向时,我已经进行了编码,以便可以获取值并基于该值打开窗口。下面的例子从php重定向错误打开jquery对话框,php,jquery,dialog,Php,Jquery,Dialog,我在数据库更新后从重定向打开jquery窗口时遇到问题。当页面重定向时,我已经进行了编码,以便可以获取值并基于该值打开窗口。下面的例子 header("Location: http://localhost/sample/users/cp.php?dialog=1"); exit(); 在cp.php中,我有以下不触发窗口的代码。但是,如果我更改autoOpen:true,则窗口将在页面加载时加载。如果有人能指出我的错误,我将不胜感激。谢谢 cp.php <?php $dialog = $
header("Location: http://localhost/sample/users/cp.php?dialog=1");
exit();
在cp.php中,我有以下不触发窗口的代码。但是,如果我更改autoOpen:true,则窗口将在页面加载时加载。如果有人能指出我的错误,我将不胜感激。谢谢
cp.php
<?php
$dialog = $_GET['dialog'];
if ($dialog ==1)
{
echo '<script type="text/javascript"> dialog(); </script>';
}
?>
<script src="js/jquery-1.3.2.min.js"></script>
<script src="js/ui.dialog.js" type="text/javascript"></script>
<link href="css/redmond/jquery-ui-1.7.3.custom.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript">
function dialog() {
$(function() {
$( "#response1" ).dialog({
modal: true,
autoOpen: false,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
}
</script>
<div style="display:none" id="response1" title="Successfully updated destroy date">
<p>
<span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
You have successfully updated your destroy date. You may now close this window. Thank you.
</p>
</div>
函数对话框(){
$(函数(){
$(“#响应1”)。对话框({
莫代尔:是的,
自动打开:错误,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
}
您已成功更新销毁日期。您现在可以关闭此窗口。非常感谢。
首先,您应该升级JQuery和JQueryUI版本
这里有一个建议:
<script type="text/javascript">
$(function() {
if(<?php echo ($dialog == 1) ? 'true' : 'false' ; ?>)
{
$( "#response1" ).dialog({
modal: true,
autoOpen: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
}
});
</script>
$(函数(){
if()
{
$(“#响应1”)。对话框({
莫代尔:是的,
自动打开:对,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
}
});
这把小提琴解释了如何使用你的代码:谢谢你的回复。但是,它会出现以下错误:Parse error:syntax error,unexpected'now I get:Parse error:syntax error,unexpected':',应为','或';'在if条件下。感谢错误:解析错误:语法错误,意外的T_ENDIF。谢天谢地。抱歉,所有这些愚蠢错误的原因是我不能用我的笔记本电脑测试…np。我们都在那里:-)我现在只得到一条简短的空消息。在声明该函数的脚本之前,您回显调用
dialog()
的脚本