Capture javascript event in CherryPy to execute python function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Capture javascript event in CherryPy to execute python function

otto-21

Hi,

Is it possible to have some kind of interface between cherrypy and
javascript so that I could capture events like 'onClick=...' ?

What I want to accomplish is that a user can click on a hyperlink and
the click is captured by 'onClick' which then launches some python code
that does something useful. I do not want to leave the webpage
(CheeryPy function) I'm currently at at that point.

Anyone any ideas on how to accomplish this?

Thanks,
Regards Otto


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Capture javascript event in CherryPy to execute python function

Tim Roberts

Otto wrote:

> Is it possible to have some kind of interface between cherrypy and
> javascript so that I could capture events like 'onClick=...' ?
>
> What I want to accomplish is that a user can click on a hyperlink and
> the click is captured by 'onClick' which then launches some python code
> that does something useful. I do not want to leave the webpage
> (CheeryPy function) I'm currently at at that point.
>
> Anyone any ideas on how to accomplish this?
>  

You need to think about who the players are here.  "onClick" is running
in the browser.  CherryPy is running in the server.  There is no connection.

Now, you can certainly have your onClick handler send an HTTP request
back to your server, and update your web page based on the results.  
That's the entire principle behind AJAX.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---