Created
April 1, 2015 11:26
-
-
Save unknownuser88/bad0f03753a464f666b7 to your computer and use it in GitHub Desktop.
call.js (ajax)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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