1
2
3
4
5
6
7
8
9
10
11
12
| self.addEventListener('message', function (e) {
| let data = e.data;
| let xhr = new XMLHttpRequest();
| xhr.open(data.type, data.url, data.async === undefined ? true : data.async);
| xhr.send(data.data || {});
| xhr.onreadystatechange = function () {
| if (this.readyState === 4 && this.status === 200) {
| data.xmlText = this.responseText
| postMessage(data);
| }
| }
| });
|
|