0

I have a PHP page with a mysql connection, a select query and then i'm building a table using PHP. If i wanted to use jQuery AJAX to refresh the data on a setInterval, on the same page, how would i go about doing that? (by the way i can do it to another PHP page but i've never done it if the PHP stuff is on the same page)

2 Answers 2

1

If you want to keep making ajax calls i suggest you do long polling, which basically means you have a script that is requesting content via ajax every given time, and it will verify every time if the content has been modified, if not it will wait again and make another call.

I used jQuery Periodical updater for a chat box and it worked perfectly.

If you wnat to learn more about how jQuery and AJAX work, check out this Nettus article

Sign up to request clarification or add additional context in comments.

Comments

0

You set the param in request, for instance file.php?ajax=1

The, depending on its value, you render full html or just the necessary elements for ajax

in php:

if($_GET['ajax']) renderAjax();
else renderFullHTML();

in js:

$.get('file.php?ajax=1', function(data) {
  $('.result').html(data);
});

1 Comment

I think you missed the setInterval portion of the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.