I am writing a javascript library to abstract ajax requests to my HTTP API.
Each of my javascript functions is a wrapper for jquery's ajax call, which makes a callback to the user on completion.

Eg.

```
mylib.doThing( "foo", { success:function(){alert("done");});

```

In the case where I want to execute mylib.doFoo twice in series, I have something like:

```
mylib.doThing( "foo", { success:function(){ mylib.doThing( "bar", { success:function(){alert("done");}); });

```

For anything more that two steps, this gets messy very quickly.

Is it possible to provide a cleaner syntax, perhaps more like the following? And how would I need to implement `mylib.doThing()`?

```
mylib.doThing("foo").mylib.doThing("bar").alert("done");

```