简体   繁体   English

jQuery / JavaScript无法正确加载div?

[英]JQuery/Javascript not properly loading a div?

PHP Version 7.0 PHP 7.0版

JQuery Version 3.1.0 jQuery版本3.1.0

You can see that the everything above the code is simply copied and pasted every five seconds rather than refreshing. 您可以看到,代码上方的所有内容都只是每五秒钟复制并粘贴一次,而不是刷新。

The intention is to refresh the include every five seconds. 目的是每五秒钟刷新一次include。

Website: http://ssmsportal.cf/pages/incomingCalls.php 网站: http//ssmsportal.cf/pages/incomingCalls.php

Code: 码:

<!doctype html>
<html><head>
        <meta charset="utf-8">
        <title>ServerSide Moderation Services</title>
        <link rel="stylesheet" href="../styles/tablesStyles.css" type="text/css" />
        <link rel="stylesheet" href="../styles/incomingCallsStyle.css" type="text/css" />
        <script src="//ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script>
        <script src="../scripts/general.js" type="text/javascript"></script>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>


    <title>Whats Up?</title>

    </head>
    <body class="body">
        <?php include '../includes/header.php'; ?>
        <div class="mainContent">
            <div class="logRegArea">
                <article class="callsContent" style='padding-left: 0px; padding-right: 0px;'>
                    <header>
                        <h2 class="loginArea" style="text-align:center">Incoming Calls:</h2>
                    </header>
                    <content>
                        <div id="login">
                        <?php include '../includes/incomingCalls.php'; ?>
                        </div>
                        <script src="../scripts/jquery.js" type="text/javascript"></script>
                        <script type="text/javascript">
                            $(document).ready(function() {
                                setInterval(function () {
                                    $('#login').load('../includes/incomingCalls.php')
                                }, 5000);
                            });
                        </script>
                    </content>
                </article>
            </div>
        </div>
        <footer class="mainFooter">
            <p>This website was developed by ROBLOX user: <a href="https://www.roblox.com/users/8869935/profile" title="Made by: wattleman">wattleman</a></p>
        </footer>
    </body>
</html>

That's the normal behavior of the load function. 这是加载功能的正常行为。

You should instead try: 您应该尝试:

$.get("../includes/incomingCalls.php", function(data) {
     $("#login").html(data);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM