Hi, for some reason I don't the problem... This is part of a form check. I check the captcha code and it returns me a 0 - the test has failed. I set => hasError = true; I alert hasError and it returns "false" and therefore the next ajax function runs, which is not what I want...
Why is the 'hasError = true;' is not avialable out side the ajax call? var codeVal = $("#code").val(); $.ajax({ type: "POST", url: "inc/captcha/captcheck.php", data: "code="+codeVal, success: function(msg){ //alert(msg); if(msg == 0){ $("#code").after('<span class="error">Bitte überprüfen Sie Ihre Eingabe.</span>'); hasError = true; } } }); alert(hasError); if(hasError == false) { $(this).hide(); $.ajax({ type: "POST", url: "inc/sendemail.php", data: "name="+nameVal+"&email="+emailToVal+"&subject="+subjectVal +"&message="+messageVal, success: function(msg){ //alert(msg); $("#sendEmail").slideUp("normal", function() { $(".blue").hide(); $("#sendEmail").before('<h1>Vielen Dank!</h1><p>Ihre Email wurde an uns gesendet.</p>'); }); } }); }