Skip to content

Latest commit

 

History

History
103 lines (82 loc) · 1.6 KB

README.md

File metadata and controls

103 lines (82 loc) · 1.6 KB

Space Cats!

SpaceCat

A performant Javascript object that provides an Ajax framework.

Usage

  var spaceCat = new SpaceCat();

  spaceCat.config = {
    url: "http://jsonplaceholder.typicode.com/posts/1",
    type: "GET",
    data: {
      title: 'foo',
      body: 'bar',
      userId: 1
    },
    success: function(data){
      alert(data);
    }
  };

  spaceCat.ajax();

Required Arguments

url:
  url: 'Request Url'
type:
  type: 'POST'

Set to GET or POST. Can be set to other methods if the host allows them.

Optional Arguments

data:
  data: {
    param1: value1,
    param2: {
      key1: value1,
      key2: value2
    },
    param3: "value3",
    param4: value4,
    foo2: ["bar2", "bar 3", "bar+4"]
  }
success:
  success: function(data){
    alert(data);
  }
method:
method: true

True for async, false for sync. Defaults to true.

debugLog:
debugLog: false

Set to true to show debugging log. Defaults to false.

Example with all arguments

  var spaceCat = new SpaceCat();

  spaceCat.config = {
    url: "http://jsonplaceholder.typicode.com/posts/1",
    type: "GET",
    data: {
      title: 'foo',
      body: 'bar',
      userId: 1
    },
    method: true,
    debugLog: true,
    success: function(data){
      alert(data);
    }
  };

  spaceCat.ajax();

Let me know what you think!

Twitter: @lumberjackchef
Website: ryanpearson.net