javascript - 尝试发布到服务并获得对监视器的响应。但无法让 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')#">•</b>
--->
<cfelseif response2 contains "PONG">
<b style="color:##00ff00;" title="#URL.COGID# CONNECTED: #timeformat(now(),'h:mm:ss tt')#"><!--- ⟨•⟩--->
<img src="connected2.png" width="18" alt="Connected">
</b>
<cfelse>
<b style="color:##ff9933;" title="RETRYING: #timeformat(now(),'h:mm:ss tt')#">⟨•⟩</b>
</cfif></cfoutput>
</script>
我们得到了成功的响应(“PONG”),但无法同时显示它们。任何想法?我希望我更精通JS。
谢谢!
编辑
我决定尝试简化一切并使用以下代码:
<cfhttp url="new.wensnetwork.com/ipaws/…" 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>
解决方案
推荐阅读
- linq - COSMOS DB 加入 TOP 运算符
- elasticsearch - 匹配类型的 DSL 查询如何不起作用?
- javascript - 计算具有特定数据 ID 的选定单选按钮的值的总和
- sql - 列是 SQL Server 中匹配日期上其他唯一值的比率
- swift - 如何结合文字使用 Swift 不透明类型?
- typescript - Jest 抛出错误,在某些测试中保存到变量中,但在其他测试中不
- sql - 聚合和连接表,其中日期列位于另一个表的连续行的日期之间
- php - 如何将自定义按钮添加到 WooCommerce 产品档案
- framer-motion - Framer Motion v2 中的反应状态更新后,子组件不会与父组件一起拖动
- sql - 使用 xml 文件更改 sql 中的非空列和默认值