首页 > 解决方案 > 尝试发布到服务并获得对监视器的响应。但无法让 Javascript 工作

问题描述

我试图让两个单独的服务来监控一个平台,但一次只能让一个或另一个工作。我使用 .BAT 来访问服务,它们似乎正在连接和工作。但是当我尝试使返回的响应变暗时,就会出现问题。我一直在工作,但仍然无法得到它。通过堆栈查看任何想法,但找不到任何东西。

所以要做的第一件事就是说明 JS:

 <script type="text/javascript">

<!--
function initPing() {
/* called from Body onLoad above */

Ping();
var AckCheck = window.setInterval(function(){Ping()},10000);

}


function Ping() { 


xmlhttp=new XMLHttpRequest();


xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
     document.getElementById('IPAWS_PING_PROD').innerHTML = xmlhttp.responseText +           document.getElementById('IPAWS_PING_PROD').innerHTML;

  }
 }



xmlhttp.open("GET","../ipaws/ping_prod.cfm?    COGID=#session.prod_cog_id#&account_id=#session.account_id#",true);
xmlhttp.send();




}

// -->

<!--
function initPing2() {
/* called from Body onLoad above */

Ping2();
var AckCheck2 = window.setInterval(function(){Ping2()},10000);

}


function Ping() { 


xmlhttp2=new XMLHttpRequest();


xmlhttp2.onreadystatechange=function()
  {
  if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
    {
     document.getElementById('IPAWS_PING_TEST').innerHTML = xmlhttp2.responseText + document.getElementById('IPAWS_PING_TEST').innerHTML;

    }
  }



 xmlhttp2.open("GET","../ipaws/ping_test.cfm?   COGID=#session.test_cog_id#&account_id=#session.account_id#",true);
 xmlhttp2.send();




 }

// -->
</script>

下面是我们如何调用函数:

 <div id="IPAWS_PING_TEST" style="width:19px;height:20px;overflow:hidden;float:left;text-align:left;font-size:16px;font-weight:bold;"></div>


 <div id="IPAWS_PING_TEST" style="width:19px;height:20px;overflow:hidden;float:left;text-align:left;font-size:16px;font-weight:bold;"></div>

所以这里是一个 ping 页面的例子:

<cfparam name="URL.COGID" default="">

<cfexecute name="C:\IPAWS\_ack2.bat" 
arguments="#URL.COGID#" timeout="30"  
errorVariable="errout2" variable="response2"/>
<cfoutput>
<CFIF errout2 neq "">
<!---
<b style="color:red;" title="ERROR (RETRYING) #timeformat(now(),'h:mm:ss tt')#">&bull;</b>
--->
<cfelseif response2 contains "PONG">
<b style="color:##00ff00;" title="#URL.COGID# CONNECTED: #timeformat(now(),'h:mm:ss tt')#"><!---    &lang;&bull;&rang;--->
<img src="connected2.png" width="18" alt="Connected">
</b>
<cfelse>
<b style="color:##ff9933;" title="RETRYING: #timeformat(now(),'h:mm:ss tt')#">&lang;&bull;&rang;</b>
</cfif></cfoutput>
</script>

我们得到了成功的响应(“PONG”),但无法同时显示它们。任何想法?我希望我更精通JS。

谢谢!

编辑

我决定尝试简化一切并使用以下代码:

<cfhttp url="new.wensnetwork.com/ipaws/…&quot; method="get" result="cfhttp">
<div id="IPAWS_PING_TEST" style="width:19px;height:20px;overflow:hidden;float:left;text-align:left;font-size:16px;font-weight:bold;">#cfhttp.filecontent#</div>

标签: javascriptcoldfusion

解决方案


推荐阅读