Created
September 30, 2016 00:04
-
-
Save asika32764/942bed5c71b5a8c6eeb967bf0a72f2ec 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 AjaxHelper() { | |
| this.ajax = function(url, type, dataType, data, callback) { | |
| $.ajax({ | |
| url: url, | |
| type: type, | |
| dataType: dataType, | |
| data: data, | |
| success: callback, | |
| error: function(xhr, errorType, error) { | |
| alert('Ajax request error, errorType: ' + errorType + ', error: ' + error) | |
| } | |
| }) | |
| } | |
| } | |
| AjaxHelper.prototype.get = function(url, data, callback) { | |
| this.ajax(url, 'GET', 'json', data, callback) | |
| } | |
| AjaxHelper.prototype.post = function(url, data, callback) { | |
| this.ajax(url, 'POST', 'json', data, callback) | |
| } | |
| AjaxHelper.prototype.put = function(url, data, callback) { | |
| this.ajax(url, 'PUT', 'json', data, callback) | |
| } | |
| AjaxHelper.prototype.delete = function(url, data, callback) { | |
| this.ajax(url, 'DELETE', 'json', data, callback) | |
| } | |
| AjaxHelper.prototype.jsonp = function(url, data, callback) { | |
| this.ajax(url, 'GET', 'jsonp', data, callback) | |
| } | |
| AjaxHelper.prototype.constructor = AjaxHelper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment