Interactive interface for browsing global, full-resolution satellite imagery
getJSON: retrieves a JSON response via XHR/AJAX from the specified url and forwards the response to the specified handler
Tilak Joshicfd75c2132fa
diff --git a/js/util.js b/js/util.jsindex ed391eecc..2ab1b5b96 100644--- a/js/util.js+++ b/js/util.js@@ -17,4 +17,23 @@ SOTE.util.extractFromQuery = function(key,qs){return "";elsereturn val[1];-};\ No newline at end of file+};++/**+ * Generates a request to the server and forwards the response to the success/failure callback+ * Usage: SOTE.util.getJSON(<url>,<args to pass through>,<success callback>,<failure callback>);+ *+ * @param {String,Object,Function,Function} url is the url to send the request, args are the arguments to pass to callback, success is the callback on a successful request, failure is the callback on a failed request+ *+*/+SOTE.util.getJSON = function(url, args, success, failure){+ var successHandler = function(data,status,xhr) { return success(data,status,xhr,args); };+ var failureHandler = function(xhr,status,error) { return failure(xhr,status,error,args); };++ $.ajax({+ url: url,+ dataType: 'json',+ success: successHandler,+ error: failureHandler+ });+}