Thank you. If you have time, would you post a web2pyslice about this? Massimo
On Dec 23, 10:36 am, MrGrieves <markcarr...@gmail.com> 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 a json object (e.g. browser > window) returns a web2py "ValueError: No JSON object 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 the json-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 <mdipie...@cs.depaul.edu> wrote: > > > Can you show us an example of controller and how you call the JSON- > > RPC? > > > Massimo > > > On Dec 22, 9:12 am, MrGrieves <markcarr...@gmail.com> wrote: > > > > Hello, > > > > I'm just getting started with web2py. I'm very interested in the json- > > > 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 using json- > > > 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 web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.