0

So i have a webpage that constantly requires the output of a php file by for example adding this, there are multiple files that need to be loaded in different divs

<?php include('table1.php'); ?>

But i need it to be constantly loading every second, is there a better way to do this or how do i do this

Brad M
  • 17
  • 2
  • 5

1 Answers1

0

You can very easily and effectively load data using jQuery. Here's some examples

html

<div id="mycontent">
</div>

JS load contents of a .php file

var element = "#mycontent";
var link = "script.php";
$(element).load(link);

JS load contents of a .php file after submitting POST

var username = "test";
$.post("script.php", {
user:username
}, function(responseData)
{
    $('#mycontent').html(responseData);
});

And of course you can make functions out of these and call them either using setTimer loops, onclick events for buttons and many other ways.

Keep in mind you need to include jQuery for these to work, and although it's possible using pure JS as well, jQuery is safer and much easier.

Community
  • 1
  • 1
Cârnăciov
  • 1,169
  • 1
  • 12
  • 24