$('form[id^=comment_add]').live("submit",function()
{
var id= this.id.replace(/[^\d]+/g,'');
$.post($(this).attr('action'), $("#comment_add"+id).serialize(), function(data)
{
/*do something*/
})
.error(function(jqXHR, textStatus, errorThrown)
{
displayError(errorThrown, id);
});
reloaded();
return false;
});
Currently i am throwing a HTTP error with the response containing the json string. and then parsing the json string and showing the errors. Is this a good way or are there better ways. or which is the recommended way to display server side validation
Yes, it is good idea. Even StackOverflow throws different error codes when error appears. Use this one you're using