Welcome to weblogs.com.pk Sign in | Join | Help

HttpStatusCodeResult

HttpStatusCodeResult

HttpStatusCodeResult was added in MVC3; its instance can be returned as ActionResult from within Controller. This is useful when we are using AJAX to call the controller action from the client side. Most Javascript libraries like jQuery has support for HTTP Status codes; with such approach in place; one can write neat client code!

$.ajax({
    url: '/Admin/Add',
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    /*..removed for clarity..*/
    statusCode: {
        200: function (data) {
            alert('Saved!');
        },
        403: function (data) {
            alert(data);
        }
    }
});
Published Thursday, February 06, 2014 11:57 AM by khurram
Filed under:

Comments

No Comments

New Comments to this post are disabled