The XHR functions are versatile and very powerful, but can be cumbersome when what you want to do is not to transfer data, but just call a function. As long as the function can be invoked with a HTTP request, XHR is fine for that also, but Dojo's RPC functionality provides a better alternative.
When using dojox.rpc
, you create an object which has stub functions that take arguments and construct XHR requests behind the scenes when called.
Another good thing about dojox.rpc
is that it hides the implementation so that it becomes a natural dividing line between different parts of your application.
It might seem a bit roundabout to follow the exact dojox.rpc
specification just to get a little separation between layers in your code, and that's of course arguable. However, the most common use case for dojox.rpc
is using a remote procedure call that has already been made for you.
For instance, Dojo contains several ready-to-go services in dojox.rpc
format, hiding their exact...