When using
var 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:
if @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
Posted to HouseTrip Deck (2013-06-21 10:45)