-1

I have a chat box.. In that 2 frames One frames display all the user name... 2nd frame we get full chat of the user u click from frame one...

Now I need to reload frame2 Everytime to check whter I got msg from sender... I can use autorefresh here... BT my problem is.. how to pass a variable on function call....

// Function call

Function call ( parameter)

//Ajax call to get all msg of clicked user and display in second frame

Now I need to reload or auto refresh it every 5 second Plz help

1 Answers1

0

If you want to execute an ajax request every x seconds timeouts could be interesting for you:

var interval = 1000;  // 1000 = 1 second, 5000 = 5 seconds
function doAjax() {
    $.ajax({
            type: 'POST',
            url: 'test.php',
            data: $(this).serialize(),
            success: function (data) {
                    // do whatever you want
            }
      });
}
setInterval(doAjax, interval);

Links for more information:

W3Schools timeouts

Another good StackOverflow question here


Hope I could help!

Fipsi
  • 670
  • 1
  • 9
  • 21