Visualizzazione dei risultati da 1 a 2 su 2

Discussione: funzione con handler

  1. #1
    Utente di HTML.it L'avatar di strae
    Registrato dal
    Apr 2008
    Messaggi
    407

    funzione con handler

    ciao ragazzi,
    in alcuni script ajax uso questa sintassi per la funzione CreateXmlHttpReq:
    Codice PHP:
    myRequest CreateXmlHttpReq(function() {myHandler(paramtetro1parametro2)}); 
    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(paramtetro1parametro2)});
    //trancio i dati della richiesta che tanto non interessano

    function myHandler(paramtetro1parametro2){
     if (
    myRequest.readyState == && 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');
       }
      }
     }

    You HAVE to assume your visitor is a maniac serial killer, out to destroy your application. And you have to prevent it.
    I can accept failure, everyone fails at something - But I can't accept not trying.

  2. #2
    Utente di HTML.it L'avatar di strae
    Registrato dal
    Apr 2008
    Messaggi
    407
    nessuno?
    You HAVE to assume your visitor is a maniac serial killer, out to destroy your application. And you have to prevent it.
    I can accept failure, everyone fails at something - But I can't accept not trying.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.