function uploadSendTextAll(link,content,name) {
var count = "";
var id_start = $("#id_start").val();
var id_end = $("#id_end").val();
$.post('/manage/iframe/member/GetMemberCount?id_start='+id_start+'&id_end='+id_end, function(data){
count = data;
var t = document.getElementById("loadpicS");
var f = document.getElementById("loadpicF");
t.innerHTML = "loading...";
var xhr = createXHR();
var oldSize=0;
var success="0";
var successP="";
var fail = "0";
var failP="";
xhr.onreadystatechange = function(){
if(xhr.readyState == 3||xhr.readyState == 4){
var result = xhr.responseText.substring(oldSize);
oldSize = xhr.responseText.length;
var obj = eval("(" + result + ")");
var failP = obj.failP;
var successP = obj.successP;
if (typeof(failP)!="undefined") {
f.innerHTML ="失败:"+ failP + "/"+count;
fail=failP;
}else {
f.innerHTML ="失败:"+ fail + "/"+count;
}
if (typeof(successP)!= "undefined") {
t.innerHTML ="成功:"+ successP + "/"+count;
success=successP;
}else {
t.innerHTML = "成功:"+success + "/"+count;
}
}
if(xhr.readyState == 4){
// 请求执行完毕
f.innerHTML = "";
t.innerHTML = "总计"+count+"条,成功"+ success+"条,失败"+fail+"条";return;
}
}
xhr.open('post','/manage/iframe/member/KfSendAll2?name='+name+'&link='+link+'&content='+content+'&id_start='+id_start+'&id_end='+id_end);
var uploadfile = document.getElementById("uploadfile").files[0]; // js 获取文件对象
var form = new FormData(); // FormData 对象
form.append("uploadfile", uploadfile); // 文件对象
xhr.send(form);
})
}
ajax 长链接,能够同时send图文,稳定性没有websocket好
最新推荐文章于 2024-06-23 13:09:36 发布