码迷,mamicode.com
首页 > Web开发 > 详细

HTA - json

时间:2019-08-17 10:54:19      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:request   response   func   start   status   call   ica   har   The   

hta,js,json

json cmd over http

<html>
<meta charset="utf-8" />
<head>
<title>Call webservice via ajax</title>
<script>
var xhr = new XMLHttpRequest();
function sendMsg() {
var name = document.getElementById(‘name‘).value;
//服务的地址
var wsUrl = ‘http://192.168.0.24:4888‘;
//请求体
var param = ‘{"command":"API_start","ver":"1.1"}‘;
//打开连接
xhr.open(‘POST‘, wsUrl, true);
//重新设置请求头
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
//xhr.setRequestHeader("SOAPAction", "http://WebXml.com.cn/getRegionCountry");
//设置回调函数
xhr.onreadystatechange = _back;
//发送请求
xhr.send(param);
}
function _back() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById(‘showInfo‘).innerHTML = xhr.responseText;
}
}
}
function sendMsg2() {
}
</script>
</head>
<body>
<input type="button" value="send command" onclick="sendMsg();">
<input type="text" id="name"><br />
<div id="showInfo">
</div>
</body>
</html>

   

HTA - json

标签:request   response   func   start   status   call   ica   har   The   

原文地址:https://www.cnblogs.com/reboost/p/9686090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!