用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2244|回复: 1
收起左侧

有懂ajax的吗,帮我弄个问题

[复制链接]
发表于 2010-12-11 09:46:19 | 显示全部楼层 |阅读模式
我有一段检测URL是不是死链的代码
function check_link_url(counts) {
var tmp = "link" + counts;
if ($("#" + tmp).html() != null) {
  $("msg_" + tmp).hide();
  var url = $("#" + tmp).html();
  ajax_check_site(url, tmp);
  counts = counts + 1;
  setTimeout("check_link_url(" + counts + ")", 800);
}
}
function ajax_check_site(url, tmp) {
$.ajax( {
  type : "POST",
  url : "/linksinfo/check_link_url",
  data : "url=" + url,
  dataType : "json",
  success : function(msg) {
   if (msg.result == 1) {
    if (msg.timeout > 2) {
     $("#msg_" + tmp).show().html('<span style="color:red">√  过慢</span>' + msg.timeout + "s");   
    } else {
     $("#msg_" + tmp).show().html("√   正常" + msg.timeout + "s");
    }
   
   } else {
    $("#msg_" + tmp).show().html("×");
   }
  },
  error : function() {
   $("#msg_" + tmp).show().html("×");
  }
});
return true;
}

counts表示总连接数 从1开始
√ 表示URL可以访问
×表示URL不能访问
现在我想把×和√的总数给记下来
不知道怎么计数
求高手指点下
发表于 2010-12-13 13:17:16 | 显示全部楼层
把要请求的URL全部放到一个数组里,然后迭代调用。然后再 success+=1;error+=1;

如果一个的调用就只能存数据库,或着存文件。

本版积分规则