I have an AJAX call that talks to my Rails controller, the AJAX is okay but the callback contains no data.
My AJAX call:
$.ajax({
url: '/get_progress/:' + this.props.myfile,
type: "GET",
dataType: "text",
success: function(data) {
console.log(data);
}.bind(this),
error: function(data) {
console.log("Error");
}.bind(this)
});
My rails controller method:
def get_progress
a = Rails.configuration.progress
render :text => a
end
My routes:
get '/get_progress/:id' => 'myfiles#get_progress'
My AJAX Success callback has no data in it, why is my a
value not passed back?
Your url
is incorrect, the :id
is meant to just be the value of the ID:
$.ajax({
url: '/get_progress/' + this.props.myfile,
type: "GET",
dataType: "text",
success: function(data) {
console.log(data);
},
error: function(data) {
console.log("Error");
}
});