简体   繁体   English

为什么在第二次和第三次调用之后ajax load()不起作用?

[英]Why doesn't ajax load() work after second and third call?

I've been trying to get my three update same time when I click button to get update it will count for new feeds, notifications and messages. 我一直在尝试同时单击按钮以获取三个更新,以获取新的供稿,通知和消息。 I've tried by using setInterval( "getupdate()", 10000 ) too, to get update automatically every 10 seconds but doesn't work for second and third divs. 我也尝试过使用setInterval( "getupdate()", 10000 ) ,以每10秒自动获取一次更新,但不适用于第二个和第三个div。

Or because Ajax doesn't support many load() call? 还是因为Ajax不支持许多load()调用?

Now, I have no idea how should I do and need your helps. 现在,我不知道该怎么办,需要您的帮助。 Thanks. 谢谢。

Javascript Java脚本

</script>

function getupdate(){
    $('#newsfeed').load('getnewsfeed.php');
    $('#notify').load('getnewnoti.php');
    $('#message').load('getnewmessage.php');
}

</script>

HTML 的HTML

<button type="button" onclick="getupdate()" class="btn btn-primary">Get Update</button>
<div id="newsfeed"></div>
<div id="notify"></div>
<div id="message"></div>

If it is a problem with concurrent ajax calls, you can always load them in sequence: 如果并发ajax调用存在问题,则可以始终按顺序加载它们:

function getupdate(){
    $('#newsfeed').load('getnewsfeed.php', function(){
        $('#notify').load('getnewnoti.php', function(){
            $('#message').load('getnewmessage.php');
        });
    });
}

If this does not help, we need to see the rest of your page too please :) 如果这样做没有帮助,我们也需要查看您页面的其余部分 :)

You also need to check whether all three server methods are returning something and not an error. 您还需要检查所有三个服务器方法是否都返回了某物,而不是返回错误。

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

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