Controller has these routes: (simple example for illustration)
get :index do
render "person/index" #this view has the .ajax action in it
end
put :update, :with => :id do
@person = Person.find(params[:id])
render "person/details"
end
The .ajax call from the index.slim file:
onTestButtonClicked: function() {
return $.ajax({
type: "PUT",
url: "/update/" + contact_id,
data: {
key: value
},
success: function(data) {
return console.log("success");
}
});
}
In the end what I'm trying to accomplish is to just have the render "person/details" line from the update route replace the whole view like it would if this were a GET or a submitted form. The data that is actually being passed successfully is a JSON object used to validate some information, but simply redirecting the window on success won't actually do what I need neither will replacing part of the DOM with some part of the result data in the success callback.
Am I missing something simple here to make this work?