Something wrong with my ajax return false
Hi, I'm beginner in Javascript and Ajax. In this code below I have two validations in my form. The first part checks via ajax if the entered data already exist in the database. If not exist then everything is ok and return is true and script execute to the end (third part). But if return is false I've got this alert as I want, but I want to stop script right there. I don't want to execute script to the end (third part). Second part of form validation works fine. Please, help, where am I doing mistake?
- $('body').delegate('#gridder_addrecord', 'click', function(){
- // First part : Do ajax insert validation here
- $.ajax({
- url: "
-
- check_date_range.php
-
- ",
- type: "POST",
- data: 'date_from='+$('#date_from').val()+'&date_to='+$('#date_to').val(),
- success: function(response){
- if(response > 0){
- $('#date_from').focus();
- alert('Check your dates!!!');
- return false;
- }
- }
- });
- // Second part: Do insert validation here
- if($('#season').val() == '') {
- $('#season').focus();
- alert('Nedostaje naziv perioda');
- return false;
- }
- // Third PaArt: Pass the form data to the ajax page
- var data = $('#gridder_addform').serialize();
- $.ajax({
- url : '
-
- ajax.php?last_id=<?php
-
- ho $_GET['last_id']; ?>',
- type : 'POST',
- data : data,
- success: function() {
- LoadGrid();
- }
- });
- return false;
- });