-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob_workers.js
44 lines (37 loc) · 1.19 KB
/
job_workers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* HTML5 Web Worker function */
const worker_ajax = (url, data, callback, type) => {
var data_array, data_string, idx, req, value;
if (data === null || typeof (data) === "undefined") {
data = {};
}
if (callback === null || typeof (callback) === "undefined" ) {
callback = function () { };
}
if (type === null || typeof (type) === "undefined") {
type = 'GET';
}
data_array = [];
for (idx in data) {
value = data[idx];
data_array.push("" + idx + "=" + value);
}
data_string = data_array.join("&");
req = new XMLHttpRequest();
req.open(type, url, false);
req.setRequestHeader("Content-type", "application/json");
req.onreadystatechange = function () {
if (req.readyState === 4 && req.status === 200) {
return callback(req.responseText);
}
};
req.send(data_string);
return req;
};
const GetAllStatusesProcess = () => {
worker_ajax("/DataQuery/GetAllStatusesProcess", { 'send': true }, function (data) {
postMessage(data);
}, 'POST');
setTimeout("GetAllStatusesProcess()", 2000);
}
GetAllStatusesProcess();