get data from server and att a table each sec

<html> <head> <script src="jquery.js"></script> <!-- Biblioteca necessaria para poder usar o operador $()--> <script> $(document).ready(function() { window.setInterval(function(){ $.ajax({ //ocara quevai fazer a consulta ajax no servidor cache: false, type: "POST", url: "ajaxdata.php?action=mydata", //url + a função a ser executada data: { randn: Math.floor(Math.random() * 100) + 1 // algum parâmetro que tu queira passar }, success: function(msg) // a função que vai pegar o teu retorno e fazer algo. { var msgParsed = JSON.parse(msg); $.each(msgParsed, function(index, item){ $("#value"+index).html(item); }) } }); // Ajax Call }, 1000) }); </script> </head> <body> <TABLE> <TR> <TD>Data 1</TD> <TD id="value1">value 1</TD> </TR> <TR> <TD>Data 2</TD> <TD id="value2">value 2</TD> </TR> </TABLE> </body> </html>
get data from server and att a table each sec

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.