Skip to content

Instantly share code, notes, and snippets.

@alexbeletsky
Created December 30, 2010 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbeletsky/759517 to your computer and use it in GitHub Desktop.
Save alexbeletsky/759517 to your computer and use it in GitHub Desktop.
function api_test(url, type, data, callback) {
$.ajax(
{
url: url,
type: type,
processData: false,
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data),
dataType: 'json',
async: false,
complete: function (result) {
if (result.status == 0) {
ok(false, '0 status - browser could be on offline mode');
} else if (result.status == 404) {
ok(false, '404 error');
} else {
callback($.parseJSON(result.responseText));
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment