Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jQuery

Status
Not open for further replies.

zura

Technical User
Sep 20, 2011
23
GE
This script is working correctly (alert) but in console is "undefined" (need in console 'yes' or 'no' like in alert).
Thanks for help.

Code:
var res;
if($(this).hasClass('login') == true){			
    login = $("#login").val();
    $.ajax({
        url: "testing.php",
        type: "POST",
        data: "login=" + login,
        cache: false,
        success: function(response){
            if (response == "no"){
                res = 'no';
                alert(res);	               	
               }
           else{
                res = 'yes';
                alert(res);
                }	
        }
    }); 
}
if(res == 'no'){
    console.log(res); 
    }
else{
     ...
 
Hi

Then why not move the [tt]console.log()[/tt] calls beside the [tt]alert()[/tt]s ?

Note that the [tt]alert()[/tt]s will be executed in a separate thread after the AJAX requests receives successful response, while the [tt]console.log()[/tt] will execute immediately after performing ( or not ) the AJAX request ( I mean, before any response could arrive ).

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top