简体   繁体   中英

JQuery/Javascript not properly loading a div?

PHP Version 7.0

JQuery Version 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.

Website: 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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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