|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Async help, loadJSONdoc and evalJSONrequestHi 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@... To unsubscribe from this group, send email to mochikit+unsubscribe@... For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Async help, loadJSONdoc and evalJSONrequestHi
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 On Thu, Jun 18, 2009 at 12:48 AM, Adam Yee <adamjyee@...> wrote:
-- Imri Goldberg -------------------------------------- www.algorithm.co.il/blogs/ -------------------------------------- -- insert signature here ---- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@... To unsubscribe from this group, send email to mochikit+unsubscribe@... For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |