admin管理员组文章数量:1379603
I am trying to update an old etd javascript wrapper and test client (was 1.3.x) that I have to the newer et 2.5.1 javascript implementation. I have all of the dependencies and the browser can find them all, yet I am getting errors in Firebug's console (see below)
The head of my HTML is as below:
<head>
<title>CometD Tester</title>
<link rel="stylesheet" type="text/css"href="style/style.css" />
<script type="text/javascript" src="org/etd/Cometd.js"></script>
<script type="text/javascript" src="org/etd/AckExtension.js"></script>
<script type="text/javascript" src="org/etd/ReloadExtension.js"></script>
<script type="text/javascript" src="jquery/jquery-1.9.0.js"></script>
<script type="text/javascript" src="jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="jquery/jqueryetd.js"></script>
<script type="text/javascript" src="jquery/jqueryetd-reload.js"></script>
<script type="text/javascript" src="js/myCometd.js"></script>
</head>
All of these are found by the browser. Looking at Cometd.js
I see the following:
orgetd.Cometd = function(name)
{
....
}
So is that not defining org? Note that none of the errors in the Console are from Cometd.js
. Otherwise I see no other definition of "orgetd". I would really appreciate it if anyone can help me out. I am using Tomcat 7 and below is the dir structure:
Thanks.
UPDATE - Further testing
I reduced the header to:
<head>
<title>CometD Tester</title>
<link rel="stylesheet" type="text/css"href="style/style.css" />
<script type="text/javascript" src="org/etd/Cometd.js"></script>
</head>
And removed ALL JS from the index.html. The only JS now included is the Cometd.js from the et. There is still the same error... ing from the very first line in that script:
orgetd.Cometd = function(name)
Not sure what I have missed here.
EDIT - Add jqueryetd-reload.js This is the contents of the file. It looks like it is "re-binding" functionality from the etd library to use the jquery one instead (?). I'm not up to speed enough in JS to debug this (I'm a C++ dev really).
(function($)
{
function bind(org_etd, cookie, ReloadExtension, etd)
{
// Remap etd COOKIE functions to jquery cookie functions
// Avoid to set to undefined if the jquery cookie plugin is not present
if (cookie)
{
org_etd.COOKIE.set = cookie;
org_etd.COOKIE.get = cookie;
}
var result = new ReloadExtension();
etd.registerExtension('reload', result);
return result;
}
if (typeof define === 'function' && define.amd)
{
define(['org/etd', 'jquery.cookie', 'org/etd/ReloadExtension', 'jqueryetd'], bind);
}
else
{
bind(orgetd, $.cookie, orgetd.ReloadExtension, $etd);
}
})(jQuery);
I am trying to update an old etd javascript wrapper and test client (was 1.3.x) that I have to the newer et 2.5.1 javascript implementation. I have all of the dependencies and the browser can find them all, yet I am getting errors in Firebug's console (see below)
The head of my HTML is as below:
<head>
<title>CometD Tester</title>
<link rel="stylesheet" type="text/css"href="style/style.css" />
<script type="text/javascript" src="org/etd/Cometd.js"></script>
<script type="text/javascript" src="org/etd/AckExtension.js"></script>
<script type="text/javascript" src="org/etd/ReloadExtension.js"></script>
<script type="text/javascript" src="jquery/jquery-1.9.0.js"></script>
<script type="text/javascript" src="jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="jquery/jquery.etd.js"></script>
<script type="text/javascript" src="jquery/jquery.etd-reload.js"></script>
<script type="text/javascript" src="js/myCometd.js"></script>
</head>
All of these are found by the browser. Looking at Cometd.js
I see the following:
org.etd.Cometd = function(name)
{
....
}
So is that not defining org? Note that none of the errors in the Console are from Cometd.js
. Otherwise I see no other definition of "org.etd". I would really appreciate it if anyone can help me out. I am using Tomcat 7 and below is the dir structure:
Thanks.
UPDATE - Further testing
I reduced the header to:
<head>
<title>CometD Tester</title>
<link rel="stylesheet" type="text/css"href="style/style.css" />
<script type="text/javascript" src="org/etd/Cometd.js"></script>
</head>
And removed ALL JS from the index.html. The only JS now included is the Cometd.js from the et. There is still the same error... ing from the very first line in that script:
org.etd.Cometd = function(name)
Not sure what I have missed here.
EDIT - Add jquery.etd-reload.js This is the contents of the file. It looks like it is "re-binding" functionality from the etd library to use the jquery one instead (?). I'm not up to speed enough in JS to debug this (I'm a C++ dev really).
(function($)
{
function bind(org_etd, cookie, ReloadExtension, etd)
{
// Remap etd COOKIE functions to jquery cookie functions
// Avoid to set to undefined if the jquery cookie plugin is not present
if (cookie)
{
org_etd.COOKIE.set = cookie;
org_etd.COOKIE.get = cookie;
}
var result = new ReloadExtension();
etd.registerExtension('reload', result);
return result;
}
if (typeof define === 'function' && define.amd)
{
define(['org/etd', 'jquery.cookie', 'org/etd/ReloadExtension', 'jquery.etd'], bind);
}
else
{
bind(org.etd, $.cookie, org.etd.ReloadExtension, $.etd);
}
})(jQuery);
Share
Improve this question
edited Jan 30, 2013 at 14:39
Dennis
asked Jan 30, 2013 at 14:01
DennisDennis
3,7411 gold badge23 silver badges44 bronze badges
2
- When you look at the net tab, do you see that all of the js files loaded? – epascarello Commented Jan 30, 2013 at 14:10
- @epascarello - It seems like everything is loaded alright. – Dennis Commented Jan 30, 2013 at 14:18
2 Answers
Reset to default 5So the problem was that I misunderstood the project layout from the Comet site. I should have followed the direction posted at etd primer for non-maven setups a lot more closely. Basically when you are setting up the project you download the distribution, and then you need to take the code from the war files bundled inside the tarball. SO, once you have extracted the tarball...
- Take the org folder from
etd-javascript-mon-2.5.1.war
(located in\etd-2.5.1\etd-javascript\jquery\target
) oretd-javascript-jquery-2.5.1.war
(located in\etd-2.5.1\etd-javascript\mon\target
) - Take the jquery folder from
etd-javascript-jquery-2.5.1.war
The org namespace definition was in the file org/etd.js
which I did not have before, as I wrongly assumed that it had been replace by the org/etd/Cometd.js
file. The namespaces org
and et
are defined as below starting on line 17 of that file:
// Namespaces for the etd implementation
this = this || {};
org.etd = {};
org.etd.JSON = {};
The functions are working correctly now.
Try loading jQuery before any of the other JavaScript files -
<head>
<title>CometD Tester</title>
<link rel="stylesheet" type="text/css"href="style/style.css" />
<script type="text/javascript" src="jquery/jquery-1.9.0.js"></script> <!-- load first -->
<script type="text/javascript" src="org/etd/Cometd.js"></script>
<script type="text/javascript" src="org/etd/AckExtension.js"></script>
<script type="text/javascript" src="org/etd/ReloadExtension.js"></script>
<script type="text/javascript" src="jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="jquery/jquery.etd.js"></script>
<script type="text/javascript" src="jquery/jquery.etd-reload.js"></script>
<script type="text/javascript" src="js/myCometd.js"></script>
</head>
本文标签: javascriptSimple comet application quotorg is not definedquotStack Overflow
版权声明:本文标题:javascript - Simple comet application "org is not defined" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744494969a2608965.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论