From 1b631b33e9d4e54279e6ad1cf4764369f229eef8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 17 Feb 2018 16:08:38 -0800 Subject: [PATCH] Make separate functions for HTTP get / post. --- frontends/etiquette_flask/static/common.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/static/common.js b/frontends/etiquette_flask/static/common.js index cb74fd1..2370039 100644 --- a/frontends/etiquette_flask/static/common.js +++ b/frontends/etiquette_flask/static/common.js @@ -235,7 +235,7 @@ function create_message_bubble(message_area, message_positivity, message_text, l setTimeout(function(){message_area.removeChild(message);}, lifespan); } -function post(url, data, callback) +function _request(method, url, callback) { var request = new XMLHttpRequest(); request.onreadystatechange = function() @@ -253,7 +253,17 @@ function post(url, data, callback) } }; var asynchronous = true; - request.open("POST", url, asynchronous); + request.open(method, url, asynchronous); + return request; +} +function get(url, callback) +{ + request = _request("GET", url, callback); + request.send(); +} +function post(url, data, callback) +{ + request = _request("POST", url, callback); request.send(data); }