I don't know what i did wrong in the ajax call. I want to return the data back to my script and work with it but its not returning result. Here are some things i will like to clarify as well as i am new to ajax programming. if the ajax call is successful and it returns result to the script. Where in the script will the result be. Will i have to create an array that holds the result or ... Here is the html
   <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" id="reserveform">
    <div id="response"></div>
        <div>
        <label>Name</label><input type="text" name="name" id="nameid">
    </div>
    <div>
        <label>Phone Number</label><input type="text" name="phone" id="phoneid">
    </div>
        <div>
        <button type="submit" class="btn" id="btnsubmit">Submit</button>
    </div>
   </form>
         <div id="success"></div>
//my script
$('#btnsubmit').click(function(e){
    e.preventDefault();
        var nameid = $('#nameid').val();
    var phoneid = $('#phoneid').val();
        var validate_msg = '';
       if (nameid == ''){
        validate_msg = '<p> Name is Required. </p>';    
    }
    if (phoneid == '' || ($.isNumeric(phoneid) == false)){
        validate_msg += '<p> Phone field is either empty or non numeric. </p>';
    }
    if (validate_msg != ''){
    $('#response').addClass('error').html('<strong>Please correct the errors below </strong>' +  validate_msg);
    } else {
        var formData = $('form #reserveForm').serialize();
        submitForm(formData);
    }
});
    function submitForm(formData){
        $.ajax({
            type: 'POST',
            url: 'reservation.php',
            data:formData,
            dataType:'json',
            success: function(data){
                $("#success").html(data);
            },
            error: function(XMLHttpResponse, textStatus, errorThrown){
                    $('#success').removeClass().addClass('error').html('<p>There was an ' + errorThrown + ' due to ' + textStatus + 'condition');
            }
        });
    }
 
     
     
     
     
    