未定义未捕获的参考错误提升ajax [英] Uncaught reference error lift ajax is not defined
问题描述
我正在尝试创建一个Lift聊天服务器.我直接从Lift书中获取所有内容,这些书从Lift的主要网站链接到.在运行它时,我无法提交消息,因为liftAjax是未定义的,并导致在chrome控制台中显示错误.
I'm trying to create a Lift chat server. I've taken everything straight from the Lift book that is linked to from Lift's main website. Upon running it, I cannot submit my messages because liftAjax is undefined and causes an error that appears in my chrome console.
如果我错了,请纠正我,但是Lift在启动网站时不应该生成liftAjax东西吗?我感觉自己可以从某些来源导入liftAjax,它可以工作,但我不认为我必须这样做.
Correct me if I'm wrong, but shouldn't Lift generate the liftAjax stuff upon starting up the website? I have a feeling I could import liftAjax myself from some source and it would work, but I don't feel I should have to do this.
这是我的index.html文件.
This is my index.html file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Home</title></head>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<!-- the behavior of the div -->
<div class="lift:comet?type=Chat">Some chat messages
<ul>
<li>A message</li>
<li class="clearable">Another message</li>
<li class="clearable">A third message</li>
</ul>
</div>
<div>
<form class="lift:form.ajax">
<input class="lift:ChatIn" id="chat_in" />
<input type="submit" value="Say Something" />
</form>
</div>
</div>
</body>
</html>
这是生成的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div id="main" xmlns="http://www.w3.org/1999/xhtml">
<!-- the behavior of the div -->
<div id="F156429460218VSI1GX_outer" style="display: inline">
<div id="F156429460218VSI1GX" style="display: inline">
<div xmlns="http://www.w3.org/1999/xhtml">Some chat messages
<ul>
<li></li>
</ul>
</div><script type="text/javascript">
// <![CDATA[
/* JSON Func comet $$ F156429460221QEXVXK */function F156429460221QEXVXK(obj) {liftAjax.lift_ajaxHandler('F156429460221QEXVXK='+ encodeURIComponent(JSON.stringify(obj)), null,null);}
// ]]>
</script></div><script type="text/javascript">
// <![CDATA[
var destroy_F156429460218VSI1GX = function() {}
// ]]>
</script></div>
<div>
<form id="F156429460223BHVYIM" action="javascript://" onsubmit="liftAjax.lift_ajaxHandler(jQuery('#'+"F156429460223BHVYIM").serialize(), null, null, "javascript");return false;">
注意:错误发生在上一行
Note: the error happens on the above line
<input name="F1564294602245ECYAU" id="chat_in" xmlns="http://www.w3.org/1999/xhtml" />
<input value="Say Something" type="submit" xmlns="http://www.w3.org/1999/xhtml" />
</form>
</div>
</div>
我只是不确定是什么原因造成的.我刚刚开始学习Lift,所以我并不了解.我想念什么吗?
I'm just not really sure what could be causing this. I'm just starting to learn Lift so I do not know much. Am I missing something?
如果您需要更多信息,例如build.sbt或其他文件,请告诉我,我也可以发布它们.
If you need more information, such as build.sbt or other files just let me know and I can post them as well.
推荐答案
在我的情况下,我缺少了body
部分,该部分似乎是自动生成liftAjax
的.
In my case, I was missing following body
part that automatically seems to source liftAjax
.
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
......
</div>
</body>
但是,在另一种情况下,手动注入jquery
可以与在Boot.scala
中注入的JQuery
模块一起使用.
But, in another case, sourcing jquery
manually would work with JQuery
module injected in Boot.scala
.
<script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
这篇关于未定义未捕获的参考错误提升ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!