Edit on GitHub

JavaScript Client

Of course, you’re able to call your ServiceStack webservice from your ajax and JavaScript clients, too.

Using TypeScript

The best tooling available for Ajax clients is to use ServiceStack’s integrated TypeScript support where you can use the TypeScript JsonServiceClient with TypeScript Add ServiceStack Reference DTO’s to get the same productive end-to-end Typed APIs available in ServiceStack’s Typed .NET Clients, e.g:

var client = new JsonServiceClient(baseUrl);

var request = new Hello();
request.Name = "World";

  .then(r => console.log(r.Result));

Using JavaScript JsonServiceClient

We also provide our own JsonServiceClients which mimics the .NET Clients in functionality that we make use of in our Redis Admin UI:

Although most dynamic languages like JavaScript already include support for HTTP and JSON where in most cases it’s easier to just use the libraries already provided. Here are a couple of examples from Backbones Todos and Redis StackOverflow that uses jQuery to talk to back-end ServiceStack JSON services:

Using jQuery:

$.getJSON("http://localhost/Backbone.Todo/todos", function(todos) {
    alert(todos.length == 1);

$.post("questions", { 
  UserId: authUser.Id, Title: title, Content: body, Tags: dtoTags 
}, refresh);

JSV Service Client

In our pursuit to provide the fastest end-to-end communication we’ve also developed a JsvServiceClient in JavaScript that uses the fast JSV Format:

JSV is marginally faster than safe JSON in modern browsers (marginally slower than Eval) but because of the poor JS and String Performance in IE7/8 it performs over 20x slower than IE’s native eval().