Javascript 未捕获的 ReferenceError:未定义日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32564028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught ReferenceError: date is not defined
提问by Sebastian Jennings Almnes
Hey I'm trying to create a heartbeat that will tell me when a customer is done with a session.
嘿,我正在尝试创建一个心跳,当客户完成会话时,它会告诉我。
My controller looks like this:
我的控制器看起来像这样:
def update
@customer = Customer.find(params[:id])
@room = Room.find(params[:room_id])
@customer.charge(@room)
@customer.update_attribute(finished_at: DateTime.now)
session[:customer_id] = nil
respond_to do |format|
format.js
format.htmt { redirect_to root_url }
end
end
now in my show.html.erb file I have this:
现在在我的 show.html.erb 文件中我有这个:
setInterval(function(){
$.post("/customers/<%= current_customer.id %>", {finished_at: date.now()}, function(){});
}, 5000);
now when I check my console the error I get is:
现在当我检查我的控制台时,我得到的错误是:
Uncaught ReferenceError: date is not defined
There might be a couple of mistakes here, anybody knows whats up?
这里可能有几个错误,有人知道怎么回事吗?