A day with .Net

My day to day experince in .net

Error handling Ajax and MVC 4

Posted by vivekcek on May 27, 2013

Write a script

function handleError(ajaxContext) {
    alert(ajaxContext.status+" "+ajaxContext.statusText);
}

Now use the OnFailure property to point to error handling function

@using (
    Ajax.BeginForm("Index", "Home", new AjaxOptions
    {
        
        UpdateTargetId = "MovieTable",
        OnFailure = "handleError"
    }))
{
    <input id="SearchBox" type="text" name="query" />
    <input id="submit" type="submit" />
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s