Ajax调用返回失败时出现了一些错误?

下面的jQuery验证运行良好,但是在Ajax调用返回失败时出现了一些错误。这里是完整的代码:http://jsfiddle.net/YJwsZ/6/

我对Ajax其实很陌生,我只是希望能够成功返回以下内容:

// AJAX call
$.ajax({
    url:url_site,
    data : data,
    // dataType: 'json',
    type: 'post',
    success: function(r){
        if (r.success) {
            alert('success');
        }
        else {
            alert('unsuccessful');
        }
    }
});

It's probably unsuccessful because url_site is not setup correctly. Re-check your path to the file you are trying to connect to. Use an absolute path if you just can't get a relative location working for you.

Try to rebuild your ajax call and add the success callback as a chained function. You also might want to create a little php script that actually answers your testcase. See the docs!

http://jsfiddle.net/VyFng/1/

$.ajax({
    url: url_site,
    data: data,
    // dataType: 'json',
    type: 'post',
}).done(function(data, textStatus, jqXHR) {
    alert(textStatus);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    alert(textStatus);
})
.always(function(dataOrJqXHR, textStatus, jqXHRorErrorThrown) {
    alert('callback after ' + textStatus + ' callback has been completed');
});