como atualizo somente os dados sem dar refresh na pagina inteira .
Olá Pessoal alguem poderia me ajudar ..Eu estou atualizando somente os dados que estou puxando de um XML, e mostrando em alert, ate ai tudo bem Oque eu queria mesmo é nao usar o alert, e sim mostrar diretamente na pagina e atualiza-lo, agora nao sei como fazer isso nao, se é preciso usar div algujma coisa parecida.... Alguem poderia me ajudar.. ou se tem outra forma! !! Codigo: teste.php<script type="text/javascript" language="javascript"> var http_request = false; var i=0;function makeRequest(url) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url, true); http_request.send(null); }function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { // alert(http_request.responseText); var xmldoc = http_request.responseXML; var root_node = xmldoc.getElementsByTagName('linha').item(i); alert(root_node.firstChild.data); makeRequest('getxml-delay.php'); i++; if (i==3){ i=0; } } else { alert('There was a problem with the request.'); } } }</script><span style="cursor: pointer; text-decoration: underline"onclick="makeRequest('getxml-delay.php')">Make a request</span>getxml-delay.php<?while ((time() % 5) != 0) { usleep (100000);}sleep (1);header("content-type: text/plain");print '<?xml version="1.0" ?>'."\n";$fh = fopen ("getxml.log","r");$i = intval(fgets($fh))+1;fclose($fh);if ($i == 4) { $i = 0; }$fh = fopen ("getxml.log","w");fwrite($fh,"$i");fclose($fh);if ($i == 0) { print '<categoria>'."\n"; print '<linha id="1" color="VM" text="Linha Ocupada">'."\n"; print "joao1\n"; print '</linha>'."\n"; print '<linha id="2" color="VM" text="Linha Ocupada">'."\n"; print "joao2\n"; print '</linha>'."\n"; print '<linha id="3" color="VM" text="Linha Ocupada">'."\n"; print "joao3\n"; print '</linha>'."\n"; print '</categoria>'."\n"; }if ($i == 1) { print '<categoria>'."\n"; print '<linha id="1" color="VM" text="Linha Ocupada">'."\n"; print "joao1\n"; print '</linha>'."\n"; print '<linha id="2" color="VM" text="Linha Ocupada">'."\n"; print "joao2\n"; print '</linha>'."\n"; print '<linha id="3" color="VM" text="Linha Ocupada">'."\n"; print "joao3\n"; print '</linha>'."\n"; print '</categoria>'."\n"; }if ($i == 2) { print '<categoria>'."\n"; print '<linha id="1" color="VM" text="Linha Ocupada">'."\n"; print "joao1\n"; print '</linha>'."\n"; print '<linha id="2" color="VM" text="Linha Ocupada">'."\n"; print "joao2\n"; print '</linha>'."\n"; print '<linha id="3" color="VM" text="Linha Ocupada">'."\n"; print "joao3\n"; print '</linha>'."\n"; print '</categoria>'."\n"; }if ($i == 3) { print '<categoria>'."\n"; print '<linha id="1" color="VM" text="Linha Ocupada">'."\n"; print "joao1\n"; print '</linha>'."\n"; print '<linha id="2" color="VM" text="Linha Ocupada">'."\n"; print "joao2\n"; print '</linha>'."\n"; print '<linha id="3" color="VM" text="Linha Ocupada">'."\n"; print "joao3\n"; print '</linha>'."\n"; print '</categoria>'."\n"; }//print '</xml>';Discussão (2)
Carregando comentários...