Skip to content
Browse files

change callback checker with $.isFunction from zepto. venuesearch cha…

…nge with ajax function, for error callback
  • Loading branch information...
1 parent f1f47a4 commit effdb667bae45865afab35f6813b579bf875f072 @swznd swznd committed Jan 2, 2013
Showing with 15 additions and 7 deletions.
  1. +15 −7 js/api.js
View
22 js/api.js
@@ -50,27 +50,35 @@ this.api = (function() {
ret = resp.results;
}
- if(callback && typeof callback === "function") {
+ if($.isFunction(callback)) {
callback(ret);
}
})
}
function updateProfile(data, callback) {
$.post(APIURL+'user/update', data, function(resp) {
- if(callback && typeof callback === "function") {
+ if($.isFunction(callback)) {
callback(resp.status);
}
})
}
function venuesearch(query,callback) {
- $.get(APIURL+'venue/search?q='+query, function(resp) {
- if(resp.status == true) {
- if(callback && typeof callback === "function") {
- callback(resp.results);
+ $.ajax({
+ url: APIURL+'venue/search?q='+query,
+ success: function(resp) {
+ if(resp.status == true) {
+ if($.isFunction(callback)) {
+ callback(resp.results);
+ }
}
- }
+ },
+ error: function() {
+ if($.isFunction(callback)) {
+ callback(false);
+ }
+ }
})
}

0 comments on commit effdb66

Please sign in to comment.
Something went wrong with that request. Please try again.