Skip to content

Instantly share code, notes, and snippets.

@rosd89
Last active January 8, 2019 11:31
Show Gist options
  • Save rosd89/fca17c1539537bbbce7f4fc9d32e3dd9 to your computer and use it in GitHub Desktop.
Save rosd89/fca17c1539537bbbce7f4fc9d32e3dd9 to your computer and use it in GitHub Desktop.
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
});
};
@rosd89
Copy link
Author

rosd89 commented Sep 3, 2017

var ajax = new AjaxProcess('서버');
var apiServer = new AjaxProcess('api서버');

ajax.get('path', {a:'a'}, 'json', function(data){

}, function(request, status, error){

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment