I am currently working with a form in rails 3 and I am running into a totally weird situation. Basically, the form detects a successful return, but fails to detect a "400" error. Here is some code.
JQUERY:
$(".editorial_review").live('ajax:failure', function(xhr, status, error) {
alert('error');
})
.live('ajax:success', function(){$(this).parents('tr').prev('tr.main').fadeOut(); $(this).parents('tr').fade开发者_如何学运维Out(); });
});
RAILS:
def create
render :json => {:error => 'No Final Status Selected'},:status => 400 and return if params[:status].blank?
@success = send(params[:status].gsub(' ', '_'))
respond_to do |format|
format.js {head:ok}
end
end
HAML:
-semantic_form_for EditorialReview.new, :remote=>true do |f|
I've checked in firebug, and everything seems kosher, and indeed when the controller responds with head :ok
there are no problems to speak of.
Any help would be much appreciated. Thanks!
The jquery rails.js uses ajax:error
instead of ajax:failure
. Try that
精彩评论