kepware http接口 javascript开发

读取某变量的值(jquery

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://127.0.0.1:39321/iotgateway/read?ids=Channel1.Device1.tag1,Channel1.Device1.tag2",
  "method": "GET",
  "headers": {
    "Connection": "keep-alive",
    "Cache-Control": "max-age=0",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "Postman-Token": "a32a4402-a275-4490-a97a-c5bbb5be601c"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

读取某变量的值(xhr

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "http://127.0.0.1:39321/iotgateway/read?ids=Channel1.Device1.tag1,Channel1.Device1.tag2");
xhr.setRequestHeader("Connection", "keep-alive");
xhr.setRequestHeader("Cache-Control", "max-age=0");
xhr.setRequestHeader("Upgrade-Insecure-Requests", "1");
xhr.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36");
xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
xhr.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
xhr.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.9");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("Postman-Token", "5f1044cc-7e65-489c-98ee-018a8ee2820d");

xhr.send(data);

浏览全部变量(jquery

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://127.0.0.1:39321/iotgateway/browse",
  "method": "GET",
  "headers": {
    "Connection": "keep-alive",
    "Cache-Control": "max-age=0",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "Postman-Token": "b2ce2020-d2d4-48e0-b99a-fe7ef1141a5c"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

浏览全部变量(xhr

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "http://127.0.0.1:39321/iotgateway/browse");
xhr.setRequestHeader("Connection", "keep-alive");
xhr.setRequestHeader("Cache-Control", "max-age=0");
xhr.setRequestHeader("Upgrade-Insecure-Requests", "1");
xhr.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36");
xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
xhr.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
xhr.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.9");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("Postman-Token", "1e76bc87-4b08-4062-a439-bad6f651116e");

xhr.send(data);

猜你喜欢

转载自www.cnblogs.com/dXIOT/p/10626568.html