A Bogus
A Bogus

Reputation: 3930

JQuery post with MVC error

I am using a JQuery in an MVC appliaction post that is erroring out, is there someway to tell what the error is?

Example code -

    $.post("/Path/Action", form, function (returnHtml) {

        //do stuff

    }).error(function () { alert("error"); });

I have attached the ".error" call but that doesn't tell me the cause of the error. Thanks!

Upvotes: 0

Views: 79

Answers (3)

epascarello
epascarello

Reputation: 207501

Hopefully you debugged it on your own based on my comment, but you can get the info this way

$.post("/error/").error( function(xhrObject,statusName,statusText) {
    console.log(xhrObject,statusName,statusText);  //Passed in info via arguments
    console.log(xhrObject.status);  //get the status code via the xhr object
});​

jsFiddle example

Upvotes: 1

webdeveloper
webdeveloper

Reputation: 17288

$.ajax({  
    type: 'POST',  
    url: '/Path/Action',  
    data: form,  
    success: function (data) {  
        console.debug(data);  
    },  
    error: function (data) {  
        console.debug(data);  
    }  
}); 

Upvotes: 1

user1026361
user1026361

Reputation: 3657

.error( function (jqXHR, status, error) {
    alert(jqXHR);
    alert(status),
    alert(error);
 })

Upvotes: 1

Related Questions