Non riesco a far funzionare questa porzione di codice. In pratica, al click sul radio button, dovrebbero comparire le informazioni nei 3 span. Mi da sempre l'alert problemi con ajax.
Questo il codice html:
Questo è il codice javaScript:codice:<FORM name="guida" action="#"> <INPUT type="radio" name="radio" value="abi" checked onClick="caricaGuida(this)">Abituale <DIV id="cr"> <H2 class="center">Dati Guida Abituale</H2><TABLE border=0> <tr><td>Nome:<td><span id="nome"></span> <tr><td>Cognome:<td><span id="cognome"></span> <tr><td>Cellulare:<td> <span id="cell"></span></TABLE> </DIV> <FORM>
Questo il file dove prelevo i dati(getDati.php):codice:function caricaGuida(scelta) { var valore = scelta.value; var url = "getGuida.php?scelta="+valore; url=url+"&sid="+Math.random(); xmlHttp = getXMLHttpRequest(); xmlHttp.onreadystatechange=getDati; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function getDati() { if(xmlHttp.readyState==4) if(xmlHttp.status == 200) { var xmlDoc=xmlHttp.responseXML.documentElement; var nome = xmlDoc.getElementsByTagName("nome") var cognome = xmlDoc.getElementsByTagName("cognome") var cellulare = xmlDoc.getElementsByTagName("cellulare"); document.getElementById("nome").innerHTML=nome; document.getElementById("cognome").innerHTML=cognome; document.getElementById("cell").innerHTML=cellulare; } else alert("Problemi con AJAX"); }
Firebug (addon di firefox) mi dice che l'errore è su xmlHttp.send(null), ma non riesco a capire il perché. Potete aiutarmi. Grazie.codice:<?php header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 01 Jul 1997 05:00:00 GMT"); $scelta=$_GET["scelta"]; ?> <guida> <?php if($scelta == "abi") { ?> <response> <nome>Rosso</nome> <cognome>Bianchi</cognome> <cellulare>333</cellulare> </response> </guida> <?php } ?>

Rispondi quotando