投票系统在部署到heroku时不工作
voting system not working when deployed to heroku
我有一个"目的地"列表。每个目的地旁边都有一个LIKE按钮,还有一个赞数。我能够让这个"点赞系统"在当地运行。然而,一旦部署到heroku,"点赞计数"就会显示为"未定义",然后每当您单击点赞按钮时,点赞计数就会变为"NaN"。如何让点赞系统在我的heroku应用程序上运行??
在我的javscript控制台中,我注意到没有像应该有的那样的like_count列。。。
Schmea.rb文件:
create_table "destinations", force: :cascade do |t|
t.string "name"
t.string "address"
t.time "start_time"
t.date "date"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "trip_id"
t.integer "day_id"
t.integer "like_count"
t.integer "duration"
t.time "end_time"
结束
我在一个javscript文件中实现了点赞系统:
var like_cell = row.insertCell(2);
like_cell.innerHTML = '<input type="button" id="like-btn" type="button" value = "Like"</input>';
var like_count_cell = row.insertCell(3);
like_count_cell.innerHTML = dest.like_count;
$('#like-btn').click(function() {
dest.like_count += 1;
like_count_cell.innerHTML=dest.like_count;
console.log('hi');
console.log(dest.like_count);
console.log(dest);
sortTable();
});
function sortTable(){
var tbl = document.getElementById("destTable").tBodies[0];
var store = [];
for(var i=1, len=tbl.rows.length; i<len; i++){
var row = tbl.rows[i];
store.push([table.rows[i].cells[3].innerHTML, row]);
}
store.sort(function(x,y){
return y[0] - x[0];
});
for(var j=0, len=store.length; i<len; i++){
tbl.appendChild(store[j][1]);
}
table = tbl;
store = null;
}
发生此类事件的可能性1.JS文件是否加载并且没有错误?2.ajax是否正在调用正确的url。(很可能它正在调用localhost,正如您所说的那样,它正在本地工作)3.ajax请求需要很长时间吗?(heroku超时30秒)4.是否存在跨浏览器问题?这就像试图从其他站点和非安全位置加载内容(比如https站点从http服务请求内容)
使用chrome/ffirefox中的js控制台调试
相关文章:
- gmap4rails在本地工作,但没有;不要出现在heroku上
- 为什么我的下拉菜单在本地服务器上可以工作,但当我推到heroku时却不能
- JQuery 事件不是在生产中处理 heroku,而是在开发中工作
- Nicedit在本地工作,但不是Heroku
- rails 预编译 为什么 javascript 在本地不起作用,但在 heroku 它可以工作
- JavaScript在开发中工作,而不是在生产中工作(Heroku)
- Heroku 生产:Gmaps 未定义 - 在本地工作
- JavaScript 不会在 Heroku 上加载,而是在本地工作
- Sails JS - 显示闪存消息在 Heroku(生产)上不起作用,但在开发中工作正常
- 投票系统在部署到heroku时不工作
- heroku上的后台工作网络是如何知道的's结束了
- Rails 4-Javascript没有'在Heroku部署后无法工作
- 莫代尔没有在heroku上工作;但在本地运行良好
- moment.js的isoWeek不能在Heroku实例上工作
- 套接字.io + NodeJS不能在Heroku上工作
- SSE在Heroku上没有像预期的那样工作
- 单个Javascript函数不能在Heroku上工作
- ruby on rails-Javascript在本地工作,但在部署到Heroku时不再工作.(带涡轮连杆.)
- Rails: jQuery在本地主机上工作,但不能在heroku上生产
- 内联Javascript不是Rails Heroku不工作