What should i return to browser if server didn't do what user expected while processing ajax request
<p>i got simple jquery function:</p>

<pre><code>function newCategoryAjax() {
    $.post("/ajax/addcategory", {
        name: $('#id_new_category').val()
    }).done(function (obj, sta) {
        $('select#id_category').append($('&lt;option&gt;', {
            value: obj.id,
            text: obj.name,
            selected: true
        })).multiselect('refresh');

    });
}
</code></pre>

<p>My server responds with new category id and name on success.
But there are instances when server wont do what user expects - ie. didn't create category because 'name' failed validation or there is already category with this name. </p>

<p>What is best practice, what my server should return in this case? Should response still have status=200 and error information in context dictionary like <code>{'error':'duplicate'}</code> or should it have status=500 or something like that? </p>