ASP.NET MVC: Is it "wrong" to use HTTP 500 via an AJAX request to return invalid form content?

Posted by Daniel Schaffer on Stack Overflow See other posts from Stack Overflow or by Daniel Schaffer
Published on 2010-03-26T18:51:24Z Indexed on 2010/03/26 18:53 UTC
Read the original article Hit count: 404

Filed under:
|
|

Here's the situation:

I've got two partial views. One has a form.

What needs to happen is when the form is posted via an AJAX request, if the operation succeeds, the area with the second partial is repopulated with the content. However, if the posted data was invalid, the original partial is repopulated with an error message.

I'm using jQuery and the ajaxForm plugin to handle the form posts and responses. Would it be "wrong"/bad coding/wtf-worthy to conditionally use $.html() to replace the content in one area when it's a 200, and a different area if it's a 500?

To me, this idea smells, but I'm not sure how else to accomplish the goal.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about AJAX