In the code below It seems that if i uncomment the return true; at the bottom it seems to happen before the ajax call is complete.. is there anyway to force it to wait for the call or have the call back return true or false and have that be returned to the submit's function?
$("form").bind("submit",function() { $.ajax({url: "", cache: false, type: "POST", dataType: "json", data: $("form").serializeArray(), success: function(data) { if(data.ErrorsFound != "") { $("div#ErrorsFound").text(data.ErrorsFound); $("form#register input").each(function(i, element){ $ (element).removeClass(data.removeClasses); }); $.each(data.requiredfields, function(i, required) { if($("input#"+required.field).hasClass(required.classname) != true) { $ ("input#"+required.field).addClass(required.classname).focus(); } }); return false; } else { return true; } } }); if($("div#ErrorsFound").text() == ""){ //return true; }else{ return false; } });