I've posted a slice explaining my approach here: http://www.web2pyslices.com/main/slices/take_slice/48
Cheers Mark On Dec 23 2009, 10:12 am, mdipierro <[email protected]> wrote: > Thank you. If you have time, would you post a web2pyslice about this? > > Massimo > > On Dec 23, 10:36 am, MrGrieves <[email protected]> wrote: > > > > > I've reviewed my code while typing this reply and found that one of > > the libraries I've been trying to use does in fact allow me to connect > > (I wasn't using it correctly). I'll post the code for others to > > benefit. > > > My controller (MyData.py) is as in the documentation: > > > from gluon.tools import Service > > service = Service(globals()) > > > def call(): > > return service() > > > @service.jsonrpc > > def myfunction(a, b): > > return a + b > > > Calling the following url without sending ajsonobject (e.g. browser > > window) returns a web2py "ValueError: NoJSONobject could be decoded" > > error which I assume means that the controller is working correctly: > > http://127.0.0.1:8000/MyApp/MyData/call/jsonrpc/myfunction > > > I've tried connecting from a client page using jQuery RPC: > > http://plugins.jquery.com/project/rpc > > I still can't get it to work. > > > I'm successful using thejson-xml-rpc lib: > > http://code.google.com/p/json-xml-rpc/ > > > The following code works well. > > > var service = new rpc.ServiceProxy("/MyApp/MyData/call/jsonrpc", { > > asynchronous: false, > > protocol: "JSON-RPC", > > sanitize: false, > > methods: ['myfunction'] > > }); > > if(service.myfunction(4,5) == 9) > > alert("Success!"); > > > Thanks again! > > > Mark > > > On Dec 22, 12:28 pm, mdipierro <[email protected]> wrote: > > > > Can you show us an example of controller and how you call theJSON- > > > RPC? > > > > Massimo > > > > On Dec 22, 9:12 am, MrGrieves <[email protected]> wrote: > > > > > Hello, > > > > > I'm just getting started with web2py. I'm very interested in thejson- > > > > rpc functionality. > > > > > The documentation seems clear for the web2py side of things > > > > (http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools.Servi......). > > > > I haven't however been able to successfully connect to a service from > > > >javascript. > > > > > I'm looking for a simple example of connecting to web2py usingjson- > > > > rpc from clientjavascript. I'm hoping to find a js library that > > > > handles the protocol (as simple as it may be) but it's not a > > > > requirement. > > > > > Thanks > > > > > Mark
-- You received this message because you are subscribed to the Google Groups "web2py-users" 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/web2py?hl=en.

