I have a script that is supposed to send form data to a PHP script via ajax. Unfortunately it is not working I know that $.ajax is having an error, but I have no clue how to view that error, at the moment i have it set so error just alerts 'fail'. Without being able to find the source of the error, solving this issue is proving very tricky, how can I view this error? I have no experience debugging ajax :S Thanks!
        $('.jSubmit').click(function() {
        var form_data = $(this).closest('form').serialize();
        var form_id   = $(this).closest('form').attr("id");
        function text_success(return_data) {
            if(form_id == "page_form") {
            $('#trans_div').append('<div id="pop_up"><div>Thank you, we will be in touch shortly.</div></div>');
            $('#trans_div').css('display','block').animate({opacity: 0.9}, 800, function() {
                $('#trans_div').delay(1500).animate({opacity: 0.0}, 800, function() {
                        $(this).css('display','none');
                });
            });
            $(this).closest('form').find("input[type=text], textarea").val("");
            }
            else
            {
            //$('.form_bottom_text').html(return_data);
            alert('no');
            }
        }
        function text_failure() {
            if(form_id == "page_form") {
            //$('#trans_div').css('display','block').animate({opacity: 0.9});
            //$('#trans_div').append('<div id="pop_up"><div>Failed to send message.</div></div>');
            //$(this).closest('form').find("input[type=text], textarea").val("");
            alert('failed');
            }
            else
            {
            $('.form_bottom_text').html('Error Occurred');
            }
        }
            $.ajax ({
            url:"form.php",
            type:'POST',
            data: form_data,
            success: function(return_data) {
                text_success(return_data);
                },
            error: function() {
                //text_failure();
                alert('fail');
                }               
            });
        });
 
     
    