[Zope] Re: Calling external method from javascript
Tres Seaver
tseaver at zope.com
Wed Sep 29 11:55:39 EDT 2004
Jonathan Hobbs wrote:
> From: "Laura McCord" <Laura.McCord at doucet-austin.com>
>
>> I am having trouble with this part of my program. I have an onclick
>>function that needs to perform three things. I know that I should have a
>>javascript function that basically handles these three operations, but I
>>don't know how to call an external method from javascript. I am using a
>>zope page template if that helps. I have googled on this topic and there
>>is not a lot said about this situation. I did run across someone using
>>dtml and calling dtml methods from javascript but did not see any
>>examples on using it with zope page templates.
>>
>>Typically I would call a external function like this: <div
>>tal:content="python:here.deleteMAC()"> but this won't work.
>
>
> AFAIK javascript can not call a zope method (dtml, script or external
> method) directly, javascript has to do indirectly by loading a url into the
> browser. You can load into a window, frame, div, etc. Here is an example:
Or use XML-RPC.
> If you need to communicate between the client process (running in the users
> browser) and the server process (ie a zope routine) without the user seeing
> anything, you can accomplish this using a hidden div in your html (use
> javascript to load the url (containing your call to the external method)
> into the hidden div), this will allow you to call a zope routine and get
> some results without changing the user's browser's display. The zope routine
> you call (via the hidden div) can return javascript variables which you can
> then parse to determine what you want to do next (embed an 'onload'
> javascript command in the html returned by the zope routine to cause a
> javascript routine to execute after the hidden div is loaded).
The XML-RPC library I have used is the Virtual Cowboys library,
available from http://www.vcdn.org/Public/XMLRPC/
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope
mailing list