php - AJAX Div Retrieval every 60 seconds -


What I would like to do, it retrieves the content of a PHP file and puts it in a single div of every 60 seconds Is basically refreshing dynamic div, I have come up with the following code, though it does not seem to work

to grab PHP:

  & Lt ;? Php $ time = date ("m / d / y h: i: bit", time ()); Mysql_query ("Update DJ Set requesttime = '{$ time}' Where Username = '{$ DJ [' Username ']}'") or Die (mysql_error ()); $ Request_db = mysql_query ("SELECT * FROM requests according to = '0' '') or die (mysql_error ()); echo" & lt; Table style = \ "border: 1px solid; width: 99%; margin-left: auto; margin-right: auto; \" border = \ "1 \" & gt; "echo" & lt; TR & gt; & Lt; Th & gt; Title & lt; / Th & gt; & Lt; Th & gt; Artist & lt; / Th & gt; & Lt; Th & gt; To dedicate ... & lt; / Th & gt; & Lt; / TR & gt; "; while ($ request = mysql_fetch_array ($ request_db)) {echo" & lt; TR & gt; & Lt; TD style = \ "width: 33%; padding: 1px; \" & gt; "echo $ request ['SongName']; echo" & lt; / Td> & Lt; Td style = \ "width: 33%; \" & gt; "; echo $ request ['artist']; echo" & lt; / Td> & Lt; Td style = \ "width: 33%; \" & gt; "; resonance $ request ['dedicated']; echo" & lt; / Td> & Lt; / Tr> ";} resounds" & lt; / Table> ";? & Gt;  

The original PHP code is the only one, in which AX attribute is attached to a device with 'ajax_table'.

Javascript is:

  // javascript document xmlHttp_moniter function moniter () {xmlHttp_moniter = GetXmlHttpObject_parcel () if (xmlHttp_moniter == faucet) {warning ("Browser does not support HTTP request") Return to url = "ajax_table.php?" Random = "+ math.random () xmlHttp_moniter.onreadystatechange = stateChanged xmlHttp_moniter.open (" GET ", url, true) xmlHttp_moniter.send (zero)} function stateChanged () {if (xmlHttp_moniter.readyState == 4 || xmlHttp_moniter. readyState == "complete") {document.getElementById ( "ajax_table") innerHTML = xmlHttp_moniter.responseText setTimeout ( 'ajax_table (.)', 60000);}} function GetXmlHttpObject_parcel () {var xmlHttp_moniter = null; try {xmlHttp_moniter = new XMLHttpRequest ();} catch (e) {// internet Explorer try {xmlHttp_moniter = new ActiveXObject ( "Msxml2.XMLHTTP");} catch (e) {xmlHttp_moniter = new ActiveXObject ( "Microsoft.XMLHTTP");}} Return xmlHttp_moniter;}  

And it is on the page which is the other of the php page Is blocking.

About using jQuery-like framework to simplify your javascript In:

  $ (function () {setInterval (function () {$ .get ('ajax_table.php', function) (data) {$ ('# ajax_table'). Html (data);});}, 60 * 1000);});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -