Autor | Zpráva | ||
---|---|---|---|
majo20 Profil * |
#1 · Zasláno: 19. 10. 2009, 21:50:08
Ešte som narazil na jeden problém. Pomocou tohto kódu refreshujem časť stránky (do časti ID=main_windows sa každú sekundu načíta stránka refresh_page1.php):
<script type="text/javascript"> var xmlhttp = false ; if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest (); } catch (e) { xmlhttp = false} } function myXMLHttpRequest () { var xmlhttplocal; try { xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")} catch (e) { try { xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")} catch (E) { xmlhttplocal = false; } } if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') { try { var xmlhttplocal = new XMLHttpRequest (); } catch (e) { var xmlhttplocal = false; } } return (xmlhttplocal); } var mnmxmlhttp = Array (); var mnmString = Array (); var mnmPrevColor = Array (); var responsestring = Array (); var myxmlhttp = Array (); var responseString = new String; var i=0; var ii = 0; function ajax_update() { url = "refresh_page1.php"; target2 = document.getElementById ('main_windows'); ii = i++; var main_windows = "i=" + ii ; mnmxmlhttp = new myXMLHttpRequest (); if (mnmxmlhttp) { mnmxmlhttp.open ("POST", url, true); mnmxmlhttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded'); mnmxmlhttp.send (main_windows); errormatch = new RegExp ("^ERROR:"); target2 = document.getElementById ('main_windows'); mnmxmlhttp.onreadystatechange = function () { if (mnmxmlhttp.readyState == 4) { mnmString = mnmxmlhttp.responseText; if (mnmString.match (errormatch)) { mnmString = mnmString.substring (6, mnmString.length); target = document.getElementById ('main_windows'); target2.innerHTML = mnmString; } else { target = document.getElementById ('main_windows'); target2.innerHTML = mnmString; } } } } setTimeout('ajax_update()', 1000); } </script> Ja by som ale potreboval načítať do inej časti (napr. ID=ina_cast) ďalšiu stránku refresh_page2.php Neviete mi s tým poradiť? |
||
Časová prodleva: 16 let
|
0