Skip to content

Instantly share code, notes, and snippets.

@xunker
Created January 25, 2012 21:51
Show Gist options
  • Save xunker/1679021 to your computer and use it in GitHub Desktop.
Save xunker/1679021 to your computer and use it in GitHub Desktop.
my phonegap json call functions
function apiGet(api_path, get_params, callback_function) {
console.log("apiGet: path:" + api_path + ' params:' + h2s(get_params));
$.ajax({
"type": "GET",
"dataType": "JSON",
"accepts": "JSON",
"url": api_path,
"data": get_params,
"success": callback_function,
"error": parseApiCallError
});
}
function apiPost(api_path, post_params, callback_function) {
post_params = { "json" : JSON.stringify(post_params) };
console.log("apiPost: path:" + api_path + ' params:' + h2s(post_params));
$.ajax({
"type": "POST",
"dataType": "JSON",
"accepts": "JSON",
"url": api_path,
"data": post_params,
"success": callback_function,
"error": parseApiCallError
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment