ciao ragazzi,
in alcuni script ajax uso questa sintassi per la funzione CreateXmlHttpReq:
Codice PHP:
myRequest = CreateXmlHttpReq(function() {myHandler(paramtetro1, parametro2)});
e fin qui tutto ok, però avrei necessità che, in base ai valori restituiti da myRequest.responseText, venga eseguita una funzione o un'altra...
come faccio a passare la funzione nell'handler?
esempio:
EDIT:
Codice PHP:
myRequest = CreateXmlHttpReq(function() {myHandler(paramtetro1, parametro2)});
//trancio i dati della richiesta che tanto non interessano
function myHandler(paramtetro1, parametro2){
if (myRequest.readyState == 4 && myRequest.status == 200) {
var response = myRequest.responseText;
if(parametro2 == true){
if(response == 1){
//eseguo funzione a
}else if(response == 0){
//eseguo funzione B
}else{
alert('valori non validi');
}
}
}
}