ASP.NET MVC AJAX call return Error Message in parallel with Partial View
<p>The scenario is in an ASP.NET MVC (4,5) maxing an ajax call that returns a partial view. Sometimes however based on different situations I may need to return an error message - display something for the user for example..</p>

<p>My current approach is this. </p>

<p>in JS: </p>

<pre><code>$.ajax({
    url: url,
    type: "POST",
    data:{ id: id},
    success: function (response) {
        $("#container").html(response);
    },
    error: function (er) {

        if (er.status == "405")
            {// do someth }
        else if (er.status == "406")
                {// do someth else }
    }
});
</code></pre>

<p>In the controller: </p>

<pre><code>public ActionResult ServerMethod(int id)
{
    if (id = 0)
        return new HttpStatusCodeResult(405);
    if (id = 1)
        return new HttpStatusCodeResult(406);

    //otherwise.. 
    return PartialView("View", Model);
}   
</code></pre>

<p>I am however aware this is a hack and not a proper solution.. Is there any better way of doing this?        </p>