aboutsummaryrefslogtreecommitdiff
path: root/src/js/chrome/js/platform-ajax.js
blob: 32aac99fb051c05da058aa9df875260195989e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41


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, {

    cache: false,

    dataType: 'text',

    success:function(text) {
      // strip out everything else from the args
      options.success(text);
    },

    error:function() {
      // call with no context
      options.error();
    },

  });

};

})();