1

我有一个将数据插入数据库的 php 页面,插入后它重定向到另一个页面,我希望在插入数据时我可以向用户显示一个对话框,插入需要将近 2 分钟,所以我在开始时编写了这段代码页数

    <script src="../js/jquery-1.9.1.min.js"></script>
    <script src="../js/jquery-ui-1.10.2.custom.min.js"></script>

    <link rel="stylesheet" href="../css/jquery-ui.css" />
</head>
<script>
    function dialogsf() {
        $("#loadingsf").dialog({
            hide: 'slide',
            show: 'slide',
            autoOpen: true
        });
        $("#loadingsf").dialog('open').html("<p>Please Wait...</p>");
        alert("dfsd");
    }

    window.onload = function() {
        dialogsf();
    };
</script>
<body>
    <div id="loadingsf" title="Import"> 
        <p>Please wait ...</p>
    </div>

插入时没有出现对话框,我试过了javascript:dialogsf();从 URL 选项卡,然后我可以看到对话框,我错过了什么吗?

4

2 回答 2

0

NOTE: This is a "Suggestive" answer, used as an example.

Here's something that I use while uploading files and it works for me and you can base yourself on this idea.

The popup box that appears while everything is happening, automatically disappears once my upload has finished, and could work for you also.

HTML

<div id="load" style="display:none;"><br><br>Uploading... Please wait.<br><hr><br>Do not close this window until it has finished.</div>

<form action="upload.php" method="post" enctype="multipart/form-data" accept-charset="ISO-8859-1" name="form1" id="form1" onsubmit="return checkFields();">

<input type="submit" name="Submit" value=" Click here to UPLOAD when ready " />

CSS

<style type="text/css">
#load{
position:absolute;
z-index:1;
border:3px double #999;
background:#f7f7f7;
width:300px;
height:300px;
margin-top:-150px;
margin-left:-150px;
top:50%;
left:50%;
text-align:center;
font-family:"Trebuchet MS", verdana, arial,tahoma;
font-size:18pt;
}
</style>

JS

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript">
var ray={
ajax:function(st)
    {
        this.show('load');
    },
show:function(el)
    {
        this.getID(el).style.display='';
    },
getID:function(el)
    {
        return document.getElementById(el);
    }
}
</script>
于 2013-09-01T19:18:20.287 回答
0

请尝试以下脚本。 <p>并且</p>标签在对话框中打开。

function dialogsf() {
        $("#loadingsf").dialog({
            hide: 'slide',
            show: 'slide',
            autoOpen: true
        });

        $("#loadingsf").dialog('open').html("Please Wait...");

    }

$(function () {
    dialogsf();
    });

在 jsfiddle 中检查它 ht​​tp ://jsfiddle.net/parixit572/WNQ3B/1/

于 2013-09-01T18:34:13.193 回答