我正在尝试使用jQuery扩展来检查服务器是否存活。 这里的扩展名为:https://gist.github.com/jerone/3487795
到目前为止我的代码:
// Device scanner class
function deviceScanner(list){
this.list = list;
this.totalDevices = list.length;
this.scan = function () {
for(var i = 0; i < this.totalDevices; i++){
$.Ping(list[i],1000)
.done( function(success, url, time, on) {
found(url);
})
.fail( function(success, url, time, on) {
notFound(url);
});
}
}
this.found = function (address){
alert(address);
}
this.notFound = function (address){
alert(address);
}
}
var scanner = new deviceScanner([KVMRxDefaultIP, KVMTx1DefaultIP, KVMTx2DefaultIP]);
$("#bt1").click(function(){
scanner.scan();
});
如何在DeviceScanner中使Ping完成或失败存储结果?
答案 0 :(得分:0)
// Device scanner class
function deviceScanner(list){
var me = this; // HERE (1)
this.list = list;
this.totalDevices = list.length;
this.scan = function () {
for(var i = 0; i < this.totalDevices; i++){
$.Ping(list[i],1000)
.done( function(success, url, time, on) {
me.property_done = true; // HERE (2)
found(url);
})
.fail( function(success, url, time, on) {
me.property_failed = true; // HERE (3)
notFound(url);
});
}
}
this.found = function (address){
alert(address);
}
this.notFound = function (address){
alert(address);
}
}
var scanner = new deviceScanner([KVMRxDefaultIP, KVMTx1DefaultIP, KVMTx2DefaultIP]);
$("#bt1").click(function(){
scanner.scan();
});
&#13;