版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Kellogg_and_Nina/article/details/78280704
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>qq在线测试</title>
- <script type="text/javascript">
- function getqq(){
- //创建XMLHttpRequest对象
- var xhr = new XMLHttpRequest();
- var url = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx";
- //打开连接
- xhr.open("post",url,true);
- //设置数据类型
- xhr.setRequestHeader("content-type","text/xml;charset=utf-8");
- //设置回调函数
- xhr.onreadystatechange=function(){
- //判断是否发送成功和判断服务端是否响应成功
- if(4 == xhr.readyState && 200 == xhr.status){
- alert(xhr.responseText);
- }
- }
- //组织SOAP协议数据
- var soapXML = "<?xml version="1.0" encoding="utf-8"?>"
- +"<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
- +"<soap:Body>"
- +"<qqCheckOnline xmlns="http://WebXml.com.cn/">"
- +"<qqCode>"+document.getElementById("number").value+"</qqCode>"
- +"</qqCheckOnline>"
- +"</soap:Body>"
- +"</soap:Envelope>";
- alert(soapXML);
- //发送数据
- xhr.send(soapXML);
- }
- </script>
- </head>
- <body>
- qq号查询:<input type="text" id="number"/> <input type="button" value="查询" onclick="javascript:getqq();"/>
- </body>
- </html>