hi,
I am trying to make an example in order to understand how to work with
ajax and TG. I am doing this:
controllers.py :
class AjaxController:
@expose(format='json')
def runcommand(self):
t = datetime.datetime.now()
tiempo = time.mktime(t.timetuple())
return dict(ti=tiempo)
class Root(controllers.RootController):
@expose(template="agendatg.templates.runcommand")
def index(self):
.........
.........
ajax = AjaxController()
runcommand.kid
.... <head>
<script src="${tg.tg_js}/MochiKit.js"/>
<script type="text/javascript" src="/static/javascript/
runcommand.js"></script>
</head>
<body>
....
<script>setInterval('async_command_output("http://localhost:8080",
100000)');</script>
</body>
runcommand.js:
function async_command_output(url){
d = doSimpleXMLHttpRequest(url+"/ajax/runcommand");
d.addCallback(display_command_output);
}
function display_command_output(xmlhttp)
{
var o = evalJSONRequest(xmlhttp);
document.getElementById("command_output").innerHTML =
'<pre>'+o.data
+'</pre>';
}
I could make these things because Chris helped me in my previous post
about datagrid autorefresh :)
But I couldn't have the example working, I have an "undefined" result
in my page. I tried to debug with firebug , and it seems that I have
an error in the way which I calling the command ajax/runcommand ,
because the object Deferred has unfired status , but actually I don't
know
I need help , if someone can correct the mistake or give me an example
working ...
THANKS !!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---