Polling Database using jQuery/Ajax

Polling Database using jQuery/Ajax

Hi guys,

I am trying to do the following using AJAX using the jQuery library, can anyone suggest how I do this?

  • Poll mysql database (eg SELECT id, field1 FROM table WHERE field1 = 'xyz'  LIMIT 1)
  • if no query returned do nothing
  • if query is returned display jQuery UI dialog modal
I've got 'chunks' of this working.. it is just the joining it all together.. (jQuery doesnt wanna know lol)
I've got the initial bit (poll db, but haven't got it to return the value to a variable)
Also, the jQuery modals work fine using the jQueryUI library.

Any help would be appreciated - thanks in advance
  1.         var refreshId = setInterval(function(){
  2.      $.ajax({
  3.      type: "POST",
  4.      url: "post.php",
  5.                 data: "",
  6.      success: function(html){
  7.     $("#responsecontainer").html(html);       
  8.                               // if this is successful, return the id from the mysql record in post and generate the dialog url based on this id, eg if id returned is 5, then url will be page.php?id=5 (i need this for generating the dialog modal based on a url
  9.      }
  10.      });
  11.         }, 1000 );