ciao a tutti
http://www.gestionewebapps.net/webapps2/
ho un problema
quando clicco sul botton mi restituisce un errore "tipo non corrispondente"
ci sto sbattendo la testa da due giorni... ma non riesco a capire cosa sia
questo è il codice chiamante la funzione
Codice PHP:
<input type="button" name="Accedi" value="Accedi" id="button" onclick="InviaDati('class/login.php','msg');"/>
mentre la funzione ajax è questa
codice:
//ajax
function handleResponse(nodo){
if(myReq.readyState == 4){
if(myReq.status == 200){
//alert(myReq.responseText);
document.getElementById(nodo).innerHTML=myReq.responseText;
}else{
alert("Errore 1) AJAX non è funzionante sul tuo browser");
}
}
}
function AJAXReq(method,url,bool,containerID){
//loading
document.getElementById(containerID).innerHTML="[img]img/loading.gif[/img] Loading...";
alert(method + " " + url + " " + bool + " " + containerID + "");
//
if(window.XMLHttpRequest){
myReq = new XMLHttpRequest();
} else
if(window.ActiveXObject){
myReq = new ActiveXObject("Microsoft.XMLHTTP");
if(!myReq){
myReq = new ActiveXObject("Msxml2.XMLHTTP");
}
}
if(myReq){
//eseguo
myReq.onreadystatechange = handleResponse(containerID);
myReq.open(method,url,bool);
//myReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
myReq.send(stringa);
}else{
alert("Errore 2) AJAX non è funzionante sul tuo browser");
}
}
function PreparaDati(){
stringa = "";
var form = document.forms[0];
var numeroElementi = form.elements.length;
for(var i = 0; i < numeroElementi; i++){
if(i < numeroElementi-1){
stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
}else{
stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
}
}
}
function InviaDati(url,containerID){
PreparaDati();
//alert(stringa);
AJAXReq("POST",url,true,containerID);
}
//ajax
attendo un illuminazione fiducioso...