jQuery验证submitHandler不显示响应

I have a jQuery validation script that is working perfectly with the except of the event handler. I have simplified this post for troubleshooting purposes.

jQuery

submitHandler: function (form) {
                $.ajax({
                    type: $(form).attr("method"),
                    url: $(form).attr("action"),
                    data: $(form).serialize(),
                    dataType : "json"
                })
                .done(function (data) {
                    if (data.resp > 0 ) {
                        alert(data.message);                       
                    }
                });
                return false; // required to block normal submit since you used ajax
            },
 // rest of the validation below, truncated for clarity

The submitHandler successfully posts to my PHP script that adds a user to a database and then echoes back a json_encode() result.

PHP

<?php
    // All processing code above this line has been truncated for brevity

    if($rows == "1"){
        $resp = array("resp"=>1, "message"=>"Account created successfully. Waiting for user activation.");
    }else{
        $resp = array("resp"=>2, "message"=>"User account already exists.");
    }

    echo json_encode($resp);
?>

As you can see the idea is simple. Alert the user with the proper response message. When I run my script the user account is added successfully to the database but no alert is displayed to the user. The Console in Chrome shows no errors, what am I missing?

After some tinkering I was able to get things working the way I wanted. Here's the updated code.

jQuery

.done(function (data) {
$("#user_add_dialog").dialog({
    autoOpen: false,
    modal: true,
    close: function (event, ui) {
    },
    title: "Add User",
    resizable: false,
    width: 500,
    height: "auto"
});
$("#user_add_dialog").html(data.message);
$("#user_add_dialog").dialog("open");
});

return false; // required to block normal submit since you used ajax

PHP

<?php
    // All processing code above this line has been truncated for brevity

    if($rows == "1"){
        $resp = array("message"=>"Account created successfully. Waiting for user activation.");
    }else{
        $resp = array("message"=>"User account already exists.");
    }

    echo json_encode($resp);
?>

The data variable in the done() is a string. You have to transform it to an object like this

var response = $.parseJSON(data);

in order to access the attributes

I am sorry I missed dataType : "json" in your code in my previous answer.
Any way I tried your code and it is working. The alert shows the message. I think you have an error somewhere else. I think it has some thing to do with the array you are encoding to json(PHP part). The response you get is not complete. Try to debug your PHP and test the page separately from AJAX and see what is the result