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