ciao a tutti io ho preso in conderazione la guida ajax di questo sito ma non riesco a farlo funzionare cioè ho ripreso le varie funzioni per fare uno script stupido per capirci un po ma non va questo è lo script dovrebbe semplicemente scrivere un testo nel div cliccando su un link, cioè il mio scopo finale sarebbe di imparare a inviare variabili in get e post per script php.
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento senza titolo</title> </head> <body> <script language="javascript"> <!--// function calendar(){ var ajax = assegnaXMLHttpRequest() { var XHR = null; browserUtente = navigator.userAgent.toUpperCase(); if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object") XHR = new XMLHttpRequest(); else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) { if(browserUtente.indexOf("MSIE 5") < 0) XHR = new ActiveXObject("Msxml2.XMLHTTP"); else XHR = new ActiveXObject("Microsoft.XMLHTTP"); } return XHR; } elemento = prendiElementoDaId("contenuto-dinamico"), usaLink = true; if(ajax) { usaLink = false; ajax.open("get", "index.html?pippo=roberto", true); ajax.setRequestHeader("connection", "close"); ajax.onreadystatechange = function() { if(ajax.readyState === readyState.COMPLETATO) { if(statusText[ajax.status] === "OK") elemento.innerHTML = ajax.responseText; else { elemento.innerHTML = "Impossibile effettuare l'operazione richiesta. "; elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status]; } } } ajax.send(null); } return usaLink; } //--> </script> </body> questo link <div id="contenuto-dinamico"></div> </html>

Rispondi quotando