Jquery ajax 422 enters chrome success

I have a site that uses rails3, jquery-forms, and I am testing firefox and chome.

For testing, I get a server that returns status 422 each time.

When I submit my form, Firefox correctly removes the "error". Chrome misuses "success."

Anyone have any ideas why this might be so?

$('form').ajaxSubmit({ dataType: 'json', success: function(responseText, statusText, xhr, $form) { console.log("It hits success"); }, error: function(responseText, statusText, xhr) { console.log("It hits failure"); } }); 
+8
google-chrome ruby-on-rails jquery-forms-plugin
source share
1 answer

I assume your server code is as follows:

 def update @model = Model.find(params[:id]) @model.update_attributes(params[:model]) if @model.save render :json => @model, :status => :ok else head :unprocessable_entity # aka 422 status code end end 

So, first of all, is there any file download associated with your ajax request? Apparently, the HTTP status code cannot be used in this case. jQuery forum topic

The conditions for a successful callback are 2xx status or 304 (not changed).

0
source share

All Articles