Return value get request
Return value get request
I currently have the following code:
- $('#toevoegenForm').submit(function(){
-
- var name = $('input[name=name]').attr('value');
- var zip = $('input[name=zip]').attr('value');
- var controle = false;
-
- $.get('ajax/unique/product.php', { q: name }, function(data){
-
- var exists = false;
- $(data).find('invalid').each(function() {
- exists = true;
- });
-
- if( name == '' ){
- alert('Er is geen productnaam ingevuld.');
- } else if( exists == true ){
- alert('De ingevulde productnaam bestaat al.');
- } else if( zip == '' ){
- alert('Er is geen zip-bestand geselecteerd.');
- } else if( zip.substr(-4).toLowerCase() != '.zip' ){
- alert('Het geselecteerde bestand is een ' + zip.substr(-3) + '-bestand. Selecteer een zip-bestand.');
- $('input[name=zip]').attr('value','');
- } else {
- controle = true;
- }
-
- });
-
- //alert(controle);
-
- if( !controle ){
- return false;
- }
-
- });
This allways submits the form. When I uncomment alert(controle); it works exactly how it should be, but with the alert box. How could I make this work without the alert message?