toolmanage
Version:
'smart基础工具类npm(beast)'
30 lines (25 loc) • 812 B
JavaScript
var monitor = {};
function post(url, data) {
if (!monitor.server) {
throw new Error("please set window.monitor.server first");
}
var xhr = new XMLHttpRequest();
xhr.open("POST", monitor.server + url, true);
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xhr.send(JSON.stringify(data));
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
}
}
};
monitor.collect = function (app, device, content) {
var data = {
app: app,
device: device,
content: content
};
post("/api/monitor/collect", data);
};
module.exports={
monitor
}