Last active
August 29, 2015 14:02
-
-
Save djanix/de465f147c8d0e44ea29 to your computer and use it in GitHub Desktop.
jquery ajax call
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 loadItems(url, params, callback) { | |
$.ajax({ | |
url: url, | |
dataType: 'json', | |
contentType: 'application/json', | |
data: JSON.stringify(params), | |
type: 'POST' | |
}) | |
.done(function (data, textStatus, jqXHR) { | |
var result = ((typeof data) == "string") ? $.parseJSON(data) : data; | |
return callback(null, result); | |
}) | |
.fail(function (jqXHR, textStatus, errorThrown) { | |
return callback(['fail', errorThrown], null); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment