var SpacesApi host http spaces ru get function method args callback re

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var SpacesApi = {
host: "http://spaces.ru",
get: function (method, args, callback) {
return SpacesApi.do(method, "GET", args, callback);
},
post: function (method, args, callback) {
return SpacesApi.do(method, "POST", args, callback);
},
do: function (method, type, args, callback) {
var p = method.split(".");
args.method = p[1];
if (!args._origin)
args._origin = location.protocol + "//" + location.host;
return $.ajax({type: type, url: SpacesApi.host + "/api/" + p[0] + "/", data: args, dataType: "json"}).done(callback);
}
};