远程发送数据

博客展示了两段JavaScript代码。`ChkCategoryID`函数用于查询是否弹出用户树,会检查分类ID,若为空提示选择分类,还会调用`RemoteRun`函数进行远程检查。`RemoteRun`函数实现远程调用,通过XMLHTTP对象发送SOAP请求并处理响应。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//查询是否需要弹出用户树,当没有分类或非组分类时不需弹出
function ChkCategoryID(CatID)
{
 
 if (CatID == "")
 {
  alert("请先选择分类!");
  return false;
 }
 
 var SoapBody = "<CatID>";
 SoapBody += CatID;
 SoapBody += "</CatID>";
 
 var url = "../Common/JumpWebService.asmx";
 var MethodName = "ChkIsGroupByCatID";
 var result = RemoteRun(url, MethodName, SoapBody);

 if( result == "true")
 {
  //可以显示树
 }
 else
 {
  alert("公开分类的对象为全体,个人分类的对象为作者本身,不需指定对象!");
  return false;
 }
 return true; 
}



function RemoteRun(page, Method, SoapBody)
{
 var url = page + "?methodname=" + Method;
 var xmlhttp,dom,node,xmlDOC;
 
 var SoapHead = "<?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><" + Method + " xmlns='http://localhost'>";
 var SoapTail = "</" + Method + "></soap:Body></soap:Envelope>";

 var SoapRequest = SoapHead + SoapBody + SoapTail;
 
 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 xmlhttp.Open("POST",url,false);
 xmlhttp.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
 xmlhttp.setRequestHeader("SOAPAction", "http://localhost/"+Method);
 xmlhttp.setRequestHeader("Content-Length",SoapRequest.length);
 xmlhttp.Send(SoapRequest);
 
 if( xmlhttp.Status == 200 )
 {
  var result = xmlhttp.responseXML.getElementsByTagName(Method + "Result");
  if(result)
  {
   return result(0).text;
  }
 }

 return "失败,请检查网络是否通畅。";
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值