Nils Diewald | 33ccfb0 | 2015-01-21 20:17:23 +0000 | [diff] [blame] | 1 | // TODO: https://github.com/honza/140medley/blob/master/140medley.js |
| 2 | |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 3 | "use strict"; |
| 4 | |
| 5 | // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest |
| 6 | // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest |
| 7 | // r.addEventListener("progress", updateProgress, false); |
Nils Diewald | 996aa55 | 2014-12-02 03:26:44 +0000 | [diff] [blame] | 8 | // http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml |
| 9 | // http://stackoverflow.com/questions/6112744/load-javascript-on-demand |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 10 | var Ajax = { |
| 11 | getJSON : function (url, onload) { |
| 12 | var r = new XMLHttpRequest(); |
| 13 | r.open('GET', url, true); |
| 14 | r.setRequestHeader("Accept", "application/json"); |
| 15 | r.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
| 16 | r.onreadystatechange = function () { |
| 17 | if (this.readyState == 4) |
| 18 | onload(JSON.parse(this.responseText)); |
| 19 | }; |
| 20 | r.send(); |
| 21 | } |
| 22 | }; |
| 23 | |