Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 正在尝试在同一页上使用url中的id显示来自db的消息。信息详情仅在屏幕上闪烁一秒钟_Javascript_Php_Jquery_Html - Fatal编程技术网

Javascript 正在尝试在同一页上使用url中的id显示来自db的消息。信息详情仅在屏幕上闪烁一秒钟

Javascript 正在尝试在同一页上使用url中的id显示来自db的消息。信息详情仅在屏幕上闪烁一秒钟,javascript,php,jquery,html,Javascript,Php,Jquery,Html,url仅在按下按钮一次时更新,并且必须再次按下才能显示详细信息。我之所以可以按两次,是因为div='read'第一次显示为空白,第二次显示为详细信息。 不知道如何修复div的闪烁,以及如何在它打开到div并显示结果之前设置url 帐户页面顶部的PHP 主HTML/PHP <div id="msginbox"> <h4><strong>Inbox</strong></h4>

url仅在按下按钮一次时更新,并且必须再次按下才能显示详细信息。我之所以可以按两次,是因为div='read'第一次显示为空白,第二次显示为详细信息。 不知道如何修复div的闪烁,以及如何在它打开到div并显示结果之前设置url

帐户页面顶部的PHP

主HTML/PHP

<div id="msginbox">
                            <h4><strong>Inbox</strong></h4>
                            <table id="inbox" class="table table-bordered table-responsive ">
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Sender</th>
                                        <th>Subject</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    if (mysqli_num_rows($messageresult) > 0) {
                                        while ($row = mysqli_fetch_assoc($messageresult)) {
                                            $sub = $row["subject"];
                                            $rdate = $row["date"];
                                            $sender = $row["sender"];
                                            $messageid = $row["message_id"];
                                            $message = $row["message"];

                                            echo "<tr>";
                                            echo "<td id='left'><p>" . $rdate . "</p></td>";
                                            echo "<td id='left'><p>" . $sender . "</p></td>";
                                            echo "<td id='left'><p>" . $sub . "</p></td>";

                                            echo "<td>" . "<button value='account.php?msgid=$messageid' class='btn btn-primary replyback'>Reply</button>" . "</td>";
                                            echo "</tr>";
                                        }
                                    }
                                    ?>     
                                </tbody>
                            </table>



                        </div>
                        <div id="read">
                                <p><strong>From: </strong><?php echo $displaysender; ?><br></p>
                                <br>
                                <p><strong>Date: </strong><?php echo $displaydate; ?><br></p>
                                <br>
                                <p><strong>Subject: </strong><?php echo $displaysub; ?><br></p>
                                <br>
                                <p><strong>Message: </strong><?php echo $displaymessage; ?></p>
                                <br>
                                <button id="back">Back</button>

                            </div>

为什么不在点击事件中禁用按钮以防止第二次点击?问题是,第一次点击只会在div='read'打开后设置url,然后它不会显示任何信息,因为查询正在使用_GET运行查询,所以禁用按钮,并将其标签更改为“Loading”直到AJAX返回。仍然不会停止div在屏幕上闪烁并消失。将以$(“#msginbox”开头的部分放在以$(“#read”)开头的行之前。注意,在显示内容之前隐藏容器。
<div id="msginbox">
                            <h4><strong>Inbox</strong></h4>
                            <table id="inbox" class="table table-bordered table-responsive ">
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Sender</th>
                                        <th>Subject</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    if (mysqli_num_rows($messageresult) > 0) {
                                        while ($row = mysqli_fetch_assoc($messageresult)) {
                                            $sub = $row["subject"];
                                            $rdate = $row["date"];
                                            $sender = $row["sender"];
                                            $messageid = $row["message_id"];
                                            $message = $row["message"];

                                            echo "<tr>";
                                            echo "<td id='left'><p>" . $rdate . "</p></td>";
                                            echo "<td id='left'><p>" . $sender . "</p></td>";
                                            echo "<td id='left'><p>" . $sub . "</p></td>";

                                            echo "<td>" . "<button value='account.php?msgid=$messageid' class='btn btn-primary replyback'>Reply</button>" . "</td>";
                                            echo "</tr>";
                                        }
                                    }
                                    ?>     
                                </tbody>
                            </table>



                        </div>
                        <div id="read">
                                <p><strong>From: </strong><?php echo $displaysender; ?><br></p>
                                <br>
                                <p><strong>Date: </strong><?php echo $displaydate; ?><br></p>
                                <br>
                                <p><strong>Subject: </strong><?php echo $displaysub; ?><br></p>
                                <br>
                                <p><strong>Message: </strong><?php echo $displaymessage; ?></p>
                                <br>
                                <button id="back">Back</button>

                            </div>
$(document).ready(function () {

$('.replyback').click(function (e) {
                    e.preventDefault();
                    $('#read').css('display', 'block');
                    $('#msginbox').css('display', 'none');
                     var newurl = $(this).attr("value");
                     window.location.href = newurl;


                });
 });