Last active
January 8, 2019 11:31
-
-
Save rosd89/fca17c1539537bbbce7f4fc9d32e3dd9 to your computer and use it in GitHub Desktop.
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
| function AjaxProcess (server) { | |
| this._server = server; | |
| } | |
| AjaxProcess.prototype._ajax = function(obj){ | |
| $.ajax(obj); | |
| }; | |
| AjaxProcess.prototype.get = function(path, params, dataType, success, error) { | |
| if (!path || !dataType) { | |
| error(undefined, undefined, 'Invalid Parameter'); | |
| return; | |
| } | |
| this._ajax({ | |
| type: 'GET', | |
| url: this._server + path, | |
| data: params, | |
| dataType: dataType, | |
| success: success, | |
| error: error | |
| }); | |
| }; | |
| AjaxProcess.prototype.post = function(path, params, dataType, success, error) { | |
| if (!path || !dataType) { | |
| error(undefined, undefined, 'Invalid Parameter'); | |
| return; | |
| } | |
| this._ajax({ | |
| type: 'POST', | |
| url: this._server + path, | |
| data: params, | |
| dataType: dataType, | |
| success: success, | |
| error: error | |
| }); | |
| }; | |
| AjaxProcess.prototype.update = function(path, params, dataType, success, error) { | |
| if (!path || !dataType) { | |
| error(undefined, undefined, 'Invalid Parameter'); | |
| return; | |
| } | |
| this._ajax({ | |
| type: 'UPDATE', | |
| url: this._server + path, | |
| data: params, | |
| dataType: dataType, | |
| success: success, | |
| error: error | |
| }); | |
| }; | |
| AjaxProcess.prototype.delete = function(path, params, dataType, success, error) { | |
| if (!path || !dataType) { | |
| error(undefined, undefined, 'Invalid Parameter'); | |
| return; | |
| } | |
| this._ajax({ | |
| type: 'DELETE', | |
| url: this._server + path, | |
| data: params, | |
| dataType: dataType, | |
| success: success, | |
| error: error | |
| }); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var ajax = new AjaxProcess('서버');
var apiServer = new AjaxProcess('api서버');
ajax.get('path', {a:'a'}, 'json', function(data){
}, function(request, status, error){
});