aboutsummaryrefslogtreecommitdiff
path: root/src/js/firefox/lib/ajax.js
diff options
context:
space:
mode:
authorGravatar Trevor Elliott <trevor@galois.com>2013-06-07 11:59:57 -0700
committerGravatar Trevor Elliott <trevor@galois.com>2013-06-07 11:59:57 -0700
commit8690d56ff0bbd1031e8cc6788dd2159aac6b7adb (patch)
treed573336305dc756f357f20dd986f77cb3ceafb9b /src/js/firefox/lib/ajax.js
parentf42930c2226d07482725b03ad522c106c0bdec8b (diff)
Reorganize the build system
* Move all javascript source to src/js * Update the test runner, etc. * Do less javascript compilation
Diffstat (limited to 'src/js/firefox/lib/ajax.js')
-rw-r--r--src/js/firefox/lib/ajax.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/js/firefox/lib/ajax.js b/src/js/firefox/lib/ajax.js
new file mode 100644
index 0000000..404deee
--- /dev/null
+++ b/src/js/firefox/lib/ajax.js
@@ -0,0 +1,36 @@
+
+var fiveui = fiveui || {};
+var Request = require('request').Request;
+var _ = require('underscore');
+
+(function() {
+
+/**
+ * Use the request api to make an XHR request from the extension context.
+ * Behaves somewhat like the jQuery.ajax method, but only ever returns the text
+ * content of the response.
+ */
+exports.get = function(url, opts) {
+
+ _.defaults(opts, {
+ success: function() {},
+ error: function() {},
+ });
+
+ Request({
+
+ url: url,
+
+ onComplete:function(resp) {
+ if(resp.status == 200) {
+ opts.success(resp.text);
+ } else {
+ opts.error();
+ }
+ },
+
+ }).get();
+
+};
+
+})();