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); |
| 6 | var Ajax = { |
| 7 | getJSON : function (url, onload) { |
| 8 | var r = new XMLHttpRequest(); |
| 9 | r.open('GET', url, true); |
| 10 | r.setRequestHeader("Accept", "application/json"); |
| 11 | r.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
| 12 | r.onreadystatechange = function () { |
| 13 | if (this.readyState == 4) |
| 14 | onload(JSON.parse(this.responseText)); |
| 15 | }; |
| 16 | r.send(); |
| 17 | } |
| 18 | }; |
| 19 | |