Auto refresh included PHP file inside a DIV

后端 未结 3 825

I have a file called messages.php which runs SQL queries to a database and displays results in a $res variable

My menu.php page I used

i         


        
3条回答
  •  遇见更好的自我
    2021-01-20 21:27

    This requires the jQuery library. It could be done in pure JS, but if you're a JS beginner I recommend using jQuery.

    function reload_messages(){
        $.get("messages.php", function(data) {
            $("#id").html(data);
        });
    }
    

    You will then need to call reload_messages, for example:

    reload messages
    

    If you want to expand on the .get method, check out this page: https://api.jquery.com/jQuery.get/

提交回复
热议问题