Salve a tutti.
Il codice che di seguito posto permette il cambiamento del testo presente in un form in modo dinamico tramite onclick associati a specifici files.
Come modificare i parametri del codice affinché possano esser visualizzati anche files di tipo *.txt residenti in remoto?codice:<script type="text/javascript"> var req1 = new XMLHttpRequest(); req1.open("GET", "/templates/index.html",true); req1.send(""); var req2 = new XMLHttpRequest(); req2.open("GET", "/templates/post.html",true); req2.send(""); var req3 = new XMLHttpRequest(); req3.open("GET", "/templates/comments.html",true); req3.send(""); var req4 = new XMLHttpRequest(); req4.open("GET", "/templates/wp-layout.css",true); req4.send(""); function Display(text){ t = document.createTextNode(text); tpl = document.getElementById('template'); while (tpl.hasChildNodes()) tpl.removeChild(tpl.firstChild); tpl.appendChild(t); } </script> <a class="button" onclick="Display(req1.responseText);">Main Page</a> <a class="button" onclick="Display(req2.responseText);">Post</a> <a class="button" onclick="Display(req3.responseText);">Comments</a> <a class="button" onclick="Display(req4.responseText);">Style Sheet</a>
Cambiare unicamente l'URI della chiamata non è stata una soluzione proficua.
Grazie per l'eventuale attenzione.
Saluti, vi!


Rispondi quotando
