Created
February 2, 2012 09:27
-
-
Save nsisodiya/1722542 to your computer and use it in GitHub Desktop.
Caching Response for API Calls
This file contains 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
getCountries: function(){ | |
var self = this; | |
function onSuccessCB(DataObj) { | |
$.jCacher.add("getCountries", DataObj); | |
clk.util.com.hideProcessing(); | |
var SettingsResponse = DataObj.getData(); | |
if (SettingsResponse.error != null) { | |
clk.util.com.showErrorMessage("Unable to get Contact Info" + SettingsResponse.error); | |
}else{ | |
self.CountriesList = SettingsResponse.response; | |
} | |
}; | |
function onFailureCB(dataObj) { | |
$.jCacher.add("getCountries", DataObj); | |
clk.util.com.hideProcessing(); | |
clk.util.com.showErrorMessage(clk.locales.error.en.UpdateError); | |
}; | |
var theValue = $.jCacher.get("getCountries"); | |
if(theValue){ | |
onSuccessCB(theValue.value); | |
}else{ | |
clk.util.com.showProcessing(); | |
this.svc.getCountries(onSuccessCB,onFailureCB); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment