On 10/19/06, alskdj80 <[EMAIL PROTECTED]> wrote:
>
> I'm a beginner at javascript, so this question will probably be quite
> simple.
>
> I've been using TurboGears with MochiKit and I've been trying to do
> simple JSON. However, for the longest time, the MochiKit functions
> just would not work. Below is a simplified version of what I had:
>
> -------------------
> page.html:
> <html>
> <head>
> ...
> <script type="text/javascript" src="/tg_js/MochiKit.js"></script>
> <script type="text/javascript"
> src="/static/javascript/post.js"></script>
> ...
> <body>
> <p>View the <a href="#" onclick="requestPageList()">complete list of
> pages.</a></p>
> </body>
> ...
>
>
> post.js:
> function requestPageList() {
> var d = loadJSONDoc("${std.url('/pagelist', tg_format='json')}");
> d.addCallback(showPageList);
> }
>
> function showPageList(result) {
> ...do something
> }
> -------------------
>
>
> Basically, in my TurboGears, calling /pagelist would return a bunch of
> dict(pages=pages). I know that that stuff works perfectly.
>
> But the loadJSONDoc would never actually run (and I know that its
> deferred and all that, but eventually, I would assume it would work).
> I know that the paths were correct because I included alert("asdf");
> things all over and they were working perfectly.
>
> Then, I tried putting the javascript embedded in page.html, like so:
>
> -------------------
> page.html:
> <html>
> <head>
> ...
> <script type="text/javascript" src="/tg_js/MochiKit.js"></script>
> <script type="text/javascript" src="/static/javascript/post.js">
> function requestPageList() {
> var d = loadJSONDoc("${std.url('/pagelist', tg_format='json')}");
> d.addCallback(showPageList);
> }
>
> function showPageList(result) {
> ...do something
> }
> </script>
> ...
> <body>
> <p>View the <a href="#" onclick="requestPageList()">complete list of
> pages.</a></p>
> </body>
> ...
> -------------------
>
> Basically, I copied the contents of post.js into the <script...>
> </script> tags and suddenly everything worked.
>
>
> Does anyone know why this is the case? I really want to put javascript
> into its own .js file rather than embedding it.
This has nothing to do with MochiKit.. you should ask on the TG list.
You're probably putting the wrong path in the script tag or something.
-bob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---