jQuery .ajax submit not working in IE and Chrome

On any of my pages such as this one when you click the "Have a Question" button left column a form comes up through jQuery Tools overlay. You fill out the form, it submits to a PHP script (a local one) and if it validates and submits you get either a thank you or error message depending on what the response is from the server. Works great in FF, safari and Opera, but not in IE or Chrome. IE and Chrome just go and print the return message the .ajax looks for on a blank page with the script URL. I must have something incorrect as even my cross domain cURL ajax scripting works but not this! Here is the code

$(document).click(function() {
        $.validator.methods.equal = function(value, element, param) {
        return value == param;
    };
    var validator = $("#request").bind("invalid-form.validate", function() {
            $("#summary").html("Your form contains " + validator.numberOfInvalids() + " error(s), please fix.");
        }).validate({
            //debug: true,
            errorElement: "em",
            errorContainer: $("#summary"),
            errorPlacement: function(error, element) {
                error.appendTo( element.parent("li"));
            },
            success: function(label) {
                label.text("ok!").addClass("success");
            },
            submitHandler: function(form) {
                $("#processing").show();
            var dataString = $(form).serialize();
                $.ajax({
                type: $("#request").attr('method'),
                url: form.action,
                data: dataString,
                clearForm: true,
                success: function(data) {
                    if (data=="SuccessMail Sent") {
                        $("#formWrap, #supportHdln").hide();
                            $("#thankYou").html('<h2><span>Thank You</span> We have received your request.</h2><p>A Customer Service Representative from NinjaTrader will contact you shortly.</p>').fadeIn("slow");
                        } else {
                            $("#formWrap, #supportHdln").hide();
                            $("#error").html('<h2><span>Uh Oh</span> We are unable to process your request.</h2><p>Please make sure all fields were filled out correctly. If you are still having trouble, please <a href=\"mailto:support@ninjatrader.com?subject=Support Email\">email us</a></p>').fadeIn("slow");
                    }
                    }
                });
            return false;

           },
            rules: {
                    hs_customer_firstname: {
                    required: true,
                    minlength: 2
                },
                    hs_customer_lastname: {
                    required: true,
                    minlength: 2
                },
                    hs_customer_email: {
                    required: true,
                    email: true
                },
                    confirmEmail: {
                    required: true,
                    email: true,
                    equalTo: "#hs_customer_email"
                },
                    hs_customer_phone: {
                    required: false,
                    digits: true
                },
                    hs_category: {
                    required: true      
                },
                    hs_customLargeTextField: {
                    required: true,
                    minlength: 20
                },
                    math: {
                    required: true,
                    equal: <?php echo $randomNumTotal; ?>   
                }
            },

            messages: {
                hs_customer_firstname: {
                    required: "Please Enter Your First Name",
                    minlength: "Your First Name Must be at Least 2 Characters"
                },
                hs_customer_lastname: {
                    required: "Please Enter Your Last Name",
                    minlength: "Your Last Name Must be at Leaset 2 Characters"
                },
                hs_customer_email: {
                    required: "Please enter your email address",
                    email: "Please enter a valid email address"
                },
                confirmEmail: {
                    required: "Please Confirm Your Email Address",
                    email: "Please Enter a Valid Email Address",
                    equalTo: "Please Enter the Same Email Address as Above"
                },
                hs_customer_phone: {
                    digits: "Numbers only"
                },

                hs_category:  {
                    required: "Please Select a Category"
                },
                hs_customLargeTextField: {
                    required: "Please Leave a Comment",
                    minlength: "Your comment must be at least 20 characters"
                },
                math: {
                    required: "Please Solve the Problem",
                    equal: "Please Solve the Problem Correctly"
                }
            }
        });
    });

and here's the tiny PHP script that runs it

<?php

if(empty($_POST['hs_customer_firstname']) || empty($_POST['hs_customer_lastname']) ||
empty($_POST['hs_customer_email']) || empty($_POST['hs_category']) ||
empty($_POST['hs_customLargeTextField']) || empty($_POST['math'])) {
echo ('Success');
}

$headers = 'From: webmaster@ninjatrader.com' . "\r\n" .
       'Reply-To: webmaster@ninjatrader.com' . "\r\n" .

$firstname = $_POST['hs_customer_firstname'] ;
//more like this

mail( "email@domain.com", "Support Request",
//$_POST fields 
"From: $email");
if(mail($firstname, $lastname, $email, $category, $inquiry)) {
echo ('Mail Sent');
} else {
echo ('Error: Mail failed');
}

?>

Answers


It had to do with the random number validation, IE and Chrome didn't like the in the js code. Once I got rid of that, and removed the validation from the form page being brought in with the overlay, added it to the parent page as a separate JS file it worked. Not sure why the random num total doesn't work though. When I added the PHP function to the parent page, it didn't trigger a JS error in the validation, but the numbers didn't validate when you added them correctly. Oh well, win some lose some.


Need Your Help

Dragging and Dropping onto a scaled element

javascript jquery jquery-ui jquery-ui-draggable jquery-ui-droppable

I have a div element that I want to be able to drag onto a scaled element. However when I do this, the div element doesn't go to the right coordinates of the element but it does when I drag it arou...

MySQL index creation using JPA (Hibernate and Batoo)

mysql hibernate jpa indexing batoo

I am experimenting indexes generation using JPA. I already know JPA specifications themselves does not contemplate a standard way to generate indexes, but (some) providers support this feature. I am

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.