Posted almost 9 years ago. Visible to the public.
jQuery ajax success/done will not run callbacks if request is json but the response is empty (typical 200)
When using
Copyvar onDone = function() { ... } var onFail = function() { ... } var params = { ... } var url = ... $.ajax({ type: 'put', url: url, contentType: 'application/json; charset=utf-8', data: JSON.stringify(params), }) .done(onDone) .fail(onFail);
Always make sure your rails controller returns something:
Copyif @property.update_attributes(params[:property]) render :json => { :ok => true }, :status => :ok else render :json => { :ok => false }, :status => :unprocessable_entity end
Do not use
head :ok
render :nothing => true, :status => :ok
Or else jQuery won't run his callbacks properly