Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Async help, loadJSONdoc and evalJSONrequest
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Adam Yee  
View profile  
 More options Jun 17, 5:48 pm
From: Adam Yee <adamj...@gmail.com>
Date: Wed, 17 Jun 2009 14:48:40 -0700 (PDT)
Local: Wed, Jun 17 2009 5:48 pm
Subject: Async help, loadJSONdoc and evalJSONrequest
Hi all, I'm a newbie to MochiKit and JS, so bare with me if there are
syntax errors or design flaws.

I'm trying to achieve simple AJAX functionality (using JSON) by
submitting a single form input and displaying the input asynchronously
with .innerHTML.

My code (testpage.html and controllers.py):
http://dpaste.com/hold/56577/

The connect('form', 'onsubmit', submitClicked) doesn't seem to be
doing anything.  The json.dumps(d) is doing its job - when submit is
clicked, the page refreshes with only {"insert": "whatever text
here"}.  I can't figure out how to json.loads properly, but if I can't
get the JS to work, the the server side script won't receive any
json.  So my struggle is in sending the xmlhttprequest.

Thank you for helping,
Adam


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Imri Goldberg  
View profile  
 More options Jun 18, 8:44 am
From: Imri Goldberg <lorgan...@gmail.com>
Date: Thu, 18 Jun 2009 15:44:24 +0300
Local: Thurs, Jun 18 2009 8:44 am
Subject: Re: [mochikit] Async help, loadJSONdoc and evalJSONrequest

Hi
Try to do the connect after the page has loaded. Use addLoadEvent for that.
So your code will look something like that:

function bla() {
    connect(...);

}

addLoadEvent(bla);

Some other issues:
If you are using ajax, you don't really need form actions, the clicking
submit will do a regular (non-ajax) POST.
I usually connect to onclick if I want ajax.

It seems that you are using turbogears 2. I'm using turbogears1, so take my
advice with a grain of salt, but in tg1 you can do expose("json"), and
return a regular dict.

If you need further help with that, I'll be glad to help you off-list.

Cheers,
Imri

--
Imri Goldberg
--------------------------------------
www.algorithm.co.il/blogs/
--------------------------------------
-- insert signature here ----

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google