diff --git a/hw6.js b/hw6.js new file mode 100644 index 0000000..9dbea46 --- /dev/null +++ b/hw6.js @@ -0,0 +1,22 @@ +// JavaScript Document +ourEvent = new Event() + + +function getEvent(){ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'myserver/lastEvent/', true); + xhr.addEventListener('readystatechange', function () { + if (xhr.readyState === 4) { + return xhr.responseText; + } + }, false); +}; + +function postEvent(Event){ + var jsonEvent = JSON.stringify(Event); + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'myserver', true); + xhr.send(jsonEvent); +}; + +Collection.prototype.add = postEvent; \ No newline at end of file