RestCake services can dynamically create javascript clients for you. You just have to include the
<script> tag, and then create an instance of the client.
Example:
<!-- include the js client --<
<script type="text/javascript" src="<#= ServiceBaseUrl #>_js?jquery&base=true"></script>
<script type="text/javascript">
// Create a new instance of the js client
var g_svc = new <#= ServiceNamespace #>.<#= ServiceName #>("<#= ServiceBaseUrl #>");
function foo()
{
// Call a service method using the js client
g_svc.someServiceMethod(arg1, arg2, arg3, function(result)
{
// Success! Do something with result...
});
}
</script>
Javascript success callback signature:
function(result, userContext, textStatus, xhr|jqXhr)
Javascript error callback signature:
function(restException, userContext, xhr|jqXhr, textStatus, errorThrown, contentType)
The xhr|jqXhr depends on your version of jQuery. It's xhr pre 1.5, jqXhr for 1.5+. RestCake is just passing along some of the args that jquery returns.