Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	README.markdown

Conflicts:
	README.markdown
  • Loading branch information
jwage committed Apr 20, 2010
2 parents 1725df8 + 55e4bbc commit 356269e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions js/README.markdown
@@ -0,0 +1,47 @@
# Javascript REST Client

The Javascript REST client is an ActiveRecord style API for working with REST
services. It is built on top of jQuery and is easy to use.

All you need to do is make sure you require jQuery and jActiveResource:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script src="jActiveResource.js"></script>

Now you can get started by defining new entity:

jActiveResource.define('User', {
url: 'http://localhost/rest/server.php/user',

username: null,
password: null,

toString: function () {
return 'username=' + this.username + '&password=' + this.password;
}
});


You can start creating instances and saving them:

var user = User.create();
user.username = 'jwage';
user.password = 'password';

user.save(function (user) {
alert(user.username + ' saved!');
});

You can easily retrieve all the users with findAll():

var users = User.findAll(null, function(users) {
alert(users.length + ' users returned');
});

If you want to retrieve a single User you can use the find() method:

var user = User.find(1);
user.username = 'jon';
user.save(function (user) {
alert(user.id + ' updated');
});

0 comments on commit 356269e

Please sign in to comment.