Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'upstream/master'

Conflicts:
	README.markdown

Conflicts:
	README.markdown
  • Loading branch information...
commit 356269e1d16c6a39ab97860ee96746e2689bd0ae 2 parents 1725df8 + 55e4bbc
@jwage jwage authored
Showing with 47 additions and 0 deletions.
  1. +47 −0 js/README.markdown
View
47 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');
+ });
Please sign in to comment.
Something went wrong with that request. Please try again.