Strykes
Strykes

Reputation: 53

Using ajax to constantly refresh php output from div

I have php includes in different divs, how can i use ajax to constantly refresh the data outputted from the php file every second, I have multiple things that need to refresh, one per div

Upvotes: 1

Views: 75

Answers (2)

Abbas
Abbas

Reputation: 781

  1. Use the javascript function settimeout
  2. In the setimeout function, perform the ajax request
  3. Fill the div element with the results from the ajax request
  4. Again, use the settimeout function in the ajax response and perform the step 2 and 3.

Upvotes: 2

harry
harry

Reputation: 483

send a ajax request per second.

window.setTimeout(function () {
    $.ajax({
        // param
    });
}, 1000);

Upvotes: 0

Related Questions