Skip to content

Instantly share code, notes, and snippets.

@unknownuser88
Created April 1, 2015 11:26
Show Gist options
  • Save unknownuser88/bad0f03753a464f666b7 to your computer and use it in GitHub Desktop.
Save unknownuser88/bad0f03753a464f666b7 to your computer and use it in GitHub Desktop.
call.js (ajax)
var A = (function($) {
'use strict';
var base_url = "http://doamin.com/api/";
function call(url, data, cb) {
var requestUrl = base_url + url;
$.ajax({
url: requestUrl,
type: 'post',
dataType: 'json',
data: data,
})
.done(function(json) {
if (typeof cb == 'function') cb(data);
})
.fail(function(jqXHR, textStatus) {
if (typeof cb == 'function') cb('error');
});
}
return {
post: call
};
})($);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment