从php重定向错误打开jquery对话框

时间:2012-10-21 11:38:11

标签: php jquery dialog

在数据库更新后,我无法从重定向打开jquery窗口。当页面重定向时,我已编码,以便我可以根据该值获取值并打开窗口。示例如下。

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 个答案:

答案 0 :(得分:1)

首先,您应该升级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>

这个小提琴解释了如何使用您的代码:http://jsfiddle.net/2bxYW/