fake your webservice until your server make it..
JavaScript Ruby CSS HTML
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


jQuery Ajax Fake

Allow fake ajax calls to simulate it whenever you can't do it for real, on development environments.

This library was customized and it's original source was created by Anas Nakawa and is available at http://anasnakawa.github.com/jquery.ajax.fake.

Files structure

/ (root)
- dummy.js
- jquery.ajax.fake.js
- webservices.fake.js

Getting started

First include these files into your pages

<body >
  <script type="text/javascript" src="path/to/jquery.js" defer ></script>
  <script type="text/javascript" src="dummy.js" defer ></script>
  <script type="text/javascript" src="jquery.ajax.fake.js" defer ></script>
  <script type="text/javascript" src="webservices.fake.js" defer ></script>

Edit webservices.fake.js and define what should be the responses your webservices will return.

fake.registerWebservice('some/path/here', function( data ) {
  var response = {
    "success": {
      "propOne": "valueOne",
      "propTwo": 5,
      "...": "..."
    "error": {
      "status": 500,
      "responseText": "{\"error\": \"server_error\", \"message\": \"This is the error message\"}"

  return response;
}, 'post', 'success');

Then, to make things simple, you can define some key variables in dummy.js (or even inline, but not advised) which you can change whenever you need to test your calls for success or error.

// defines the response status
var dummyStatus = 'success';

// defines whenever ajax will fake or not your calls
var dummyAjax  = true;

// pretends a delay on the response 
var dummyDelay = 650; // 0.65 second;