diff options
Diffstat (limited to 'src/js/chrome/js/platform-ajax.js')
-rw-r--r-- | src/js/chrome/js/platform-ajax.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/js/chrome/js/platform-ajax.js b/src/js/chrome/js/platform-ajax.js new file mode 100644 index 0000000..68ced39 --- /dev/null +++ b/src/js/chrome/js/platform-ajax.js @@ -0,0 +1,39 @@ + + +var fiveui = fiveui || {}; + +(function() { + +fiveui.ajax = fiveui.ajax || {}; + +/** + * Use jQuery to get the resource, calling the success or error continuations + * when the result is returned. This always retrieves as text, leaving any + * further processing to the success continuation. + */ +fiveui.ajax.get = function(url, options) { + + _.defaults(options, { + success:function() {}, + error: function() {} + }); + + jQuery.ajax(url, { + + dataType: 'text', + + success:function(text) { + // strip out everything else from the args + options.success(text); + }, + + error:function() { + // call with no context + options.error(); + }, + + }); + +}; + +})(); |