我有一个AJAX调用,它与我的Rails控制器对话,AJAX可以,但回调不包含数据。
我的AJAX调用:
$.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)
});我的rails控制器方法:
def get_progress
a = Rails.configuration.progress
render :text => a
end我的路线:
get '/get_progress/:id' => 'myfiles#get_progress'我的AJAX成功回调中没有数据,为什么我的a值没有回传?
发布于 2015-10-29 20:45:07
您的url不正确,:id应仅为ID的值:
$.ajax({
url: '/get_progress/' + this.props.myfile,
type: "GET",
dataType: "text",
success: function(data) {
console.log(data);
},
error: function(data) {
console.log("Error");
}
});https://stackoverflow.com/questions/33408824
复制相似问题