I’ve a Rails server and I’m trying to make a PUT using the $.ajax function. The server gives a POST 200 OK but the DB data it’s not being updated.
$.ajax({type: 'POST',
url: this.SERVER_IP+ "/user_coordinates/" + this.FRIEND_ID,
dataType: 'json',
async: false,
data: {_method:'PUT',
page: {"user_coordinate":
{"meetinglat":this.meetingPoint.getPosition().lat(),
"meetinglong":this.meetingPoint.getPosition().lng()}
}
},
success: function(msg){
console.log("Sucess! Object: ");
console.log(msg);
},
error: function(msg){
console.log("Error! Object: ");
console.log(msg);
}
});
The error function is being called. What could be the problem here?
Thanks for your time 😉
I’ve the found the problem. Using logger.debug in my controller i’ve noticed that it was expecting params[:user_coordinate] and in my ajax call I was passing something like:
instead of:
Now it’s working! 😉
logger.debug “params #{params[:user_coordinate]}”