gpt4 book ai didi

javascript - 需要来自 TFS/Sharepoint 的 Ping 请求

转载 作者:行者123 更新时间:2023-11-28 07:48:26 25 4
gpt4 key购买 nike

我将使用 Visual Studio 2013 制作一个“适用于 Windows 8.1 的商店应用程序”,我需要检查 tfs 服务器是否在线/离线 https://tfs.xxx-xxx.de:8090/xxx/xxx/xxx (不是我的服务器,但获得了 url,并且我有一个帐户可以使用 Sharepoint 创建和测试一些表)

我使用 HTML/Javascript,用户应该查看服务器是否可访问。我需要的是用 Javscript 或其他东西(ajax?)进行 ping 操作。我还想要一些有关 ping 持续时间的信息以及一些 header 信息。我创建了一些按钮用于测试,稍后我将删除它们。

HTML

  <body>
<div class="main">
<button id="button_server_ok"> Green</button>
<button id="button_server_slow"> Yellow</button>
<button id="button_server_offline"> Red</button>
<button id="button_ping"> Ping </button>
</div>
<div id="response">Response</div>
<div class="status_bar">
<h3>Server State</h3>
<hr />
<svg width="50" height="50">
<circle id="server_ok" cx="25" cy="25" r="20" stroke="green" stroke-width="2" fill="#FFFFFF" />
</svg>
<svg width="50" height="50">
<circle id="server_slow" cx="25" cy="25" r="20" stroke="yellow" stroke-width="2" fill="#FFFFFF" />
</svg>
<svg width="50" height="50">
<circle id="server_offline" cx="25" cy="25" r="20" stroke="red" stroke-width="2" fill="#FFFFFF" />
</svg>
</div>
</body>

JavaScript

(function () {
"use strict";

var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;

app.onactivated = function (args)
{
if (args.detail.kind === activation.ActivationKind.launch)
{
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated)
{
// TODO: Diese Anwendung wurde neu gestartet. Die Anwendung
// hier initialisieren.
} else {
// TODO: Diese Anwendung war angehalten und wurde reaktiviert.
// Anwendungszustand hier wiederherstellen.
}



args.setPromise(WinJS.UI.processAll().then(function completed()
{

var ok = document.getElementById("button_server_ok");
ok.addEventListener("click", server_ok, false);

var slow = document.getElementById("button_server_slow");
slow.addEventListener("click", server_slow, false);

var off = document.getElementById("button_server_offline");
off.addEventListener("click", server_offline, false);

var ping= document.getElementById("button_ping");
ping.addEventListener("click", ping, false);

}));
}
};



app.oncheckpoint = function (args)
{
// TODO: Diese Anwendung wird gleich angehalten. Jeden Zustand,
// der über Anhaltevorgänge hinweg beibehalten muss, hier speichern. Dazu kann das
// WinJS.Application.sessionState-Objekt verwendet werden, das automatisch
// über ein Anhalten hinweg gespeichert und wiederhergestellt wird. Wenn ein asynchroner
// Vorgang vor dem Anhalten der Anwendung abgeschlossen werden muss,
// args.setPromise() aufrufen.
};


function server_ok(eventinfo)
{
document.getElementById("response").innerHTML = "GREEN";
document.getElementById("server_ok").setAttribute("fill", "#00FF00");

document.getElementById("server_slow").setAttribute("fill", "#FFFFFF");
document.getElementById("server_offline").setAttribute("fill", "#FFFFFF");
}

function server_slow(eventinfo)
{
document.getElementById("response").innerHTML = "YELLOW";
document.getElementById("server_slow").setAttribute("fill", "#FFFF00");

document.getElementById("server_ok").setAttribute("fill", "#FFFFFF");
document.getElementById("server_offline").setAttribute("fill", "#FFFFFF");
}

function server_offline(eventinfo)
{
document.getElementById("response").innerHTML = "RED";
document.getElementById("server_offline").setAttribute("fill", "#FF0000");

document.getElementById("server_ok").setAttribute("fill", "#FFFFFF");
document.getElementById("server_langsam").setAttribute("fill", "#FFFFFF")
}

function ping(eventinfo)
{

}

app.start();

})();

最佳答案

如果此服务器没有允许您尝试执行 ajax 请求的 cors header ,您可以尝试使用错误替代 url 从服务器加载不可见的图像,并检查图像的 url。我不知道有什么方法可以获得往返时间

关于javascript - 需要来自 TFS/Sharepoint 的 Ping 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27160093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com