#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Why does not the if(message2 === "i") run, when message2 = i?


    hi, i'm sending some data to a php script, and it's returning some data. If the data returns "i", an if statement should run, but it's just going to the else and alert's it out... but why? and how can i fix it?

    Code:
    function handleServerRespons(){
      
        if (xmlHttp.readyState === 4){
            if (xmlHttp.status === 200){
                message1 = xmlHttp.responseText;
                 teit(message1);
            }
        }
    }
        
        function teit(message2){
                   if(message2 > 1){
                       alert(url);
                       id = message2;
                       if(url === 'sections/new_visitor.php'){
                        tet('sections/whotovisit.php');
                    }else if(url === 'sections/returning_visitor.php'){
                        tet('sections/verify.php');
                    } 
                    }else if(message2 === 0){
                        var r = confirm("Tis account is already registred ");
                            if (r === true)
                              {
                              tet('sections/returning_visitor.php');
                            }
                    }else if(message2 === "i"){
                        tet('sections/iam.php');
                    }else if(message2 === 'p'){
                        tet('sections/nda.php');
                    }else if(message2 === 'n'){
                        tet('sections/wifi.php'); 
                    }else if(message2 === 'r'){
                        id = message2;
                        tet('sections/verify.php'); 
                    }else if(message2 === 'd'){
                        tet('sections/new_visitor.php'); 
                    }else if(message2 === 'w'){
                        tet('sections/thankyou.php'); 
                    }else if(message2 === 'e'){
                        error();
                }else{alert(message2);}
            }
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,158
    Rep Power
    184
    In your if... else condition; replace "===", with "==".

    This should be a little more explanatory; when it comes to "comparison operators" - https://developer.mozilla.org/en-US/...ison_operators.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    I have already tried it, but it dont work :/ but fixed it with responseXML insted tnx reply!

IMN logo majestic logo threadwatch logo seochat tools logo