Refresh a div with php data every 10 seconds using jQuery

白昼怎懂夜的黑 提交于 2019-12-02 23:34:51

jQuery load method works in a different way. Try reading its documentation.

You don't have to specify destination element ID twice, remove the second one, like this:

$("#latestData").load("getLatestData.php");

Here's a way that will solve what you want to achieve, using the $.get method in jQuery:

$(document).ready(function () {
    setInterval(function() {
        $.get("getLatestData.php", function (result) {
            $('#latestData').html(result);
        });
    }, 10000);
});
vishal

If you want to refresh message count just use this code:

$(document).ready(function () {
    setInterval(function () {
        $("#ID").load();
    }, 1000);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!