$("#alreadypost").click(function () {
function getNowFormatDate() {
var date =new Date();
? ? ? ? var seperator1 ="-";
? ? ? ? var year = date.getFullYear();
? ? ? ? var month = date.getMonth() +1;
? ? ? ? var strDate = date.getDate();
? ? ? ? var hours=date.getHours();
? ? ? ? if(hours >=0 && hours <=9){
hours ="0" + hours;
? ? ? ? }
var minutes=date.getMinutes();
? ? ? ? if(minutes >=0 && minutes <=9){
minutes ="0" + minutes;
? ? ? ? }
var seconds=date.getSeconds();
? ? ? ? if(seconds >=0 && seconds <=9){
seconds="0" + seconds;
? ? ? ? }
if (month >=1 && month <=9) {
month ="0" + month;
? ? ? ? }
if (strDate >=0 && strDate <=9) {
strDate ="0" + strDate;
? ? ? ? }
var currentdate = year + seperator1 + month + seperator1 + strDate+" "+hours+":"+minutes+":"+seconds;
? ? ? ? return currentdate;
? ? }
var nums =0;
? ? var getting={
type:"post",
? ? ? ? url:"/data/searching",
? ? ? ? contentType:"application/json",
? ? ? ? dataType:"JSON",
? ? ? ? data:null,
? ? ? ? timeout:5000,
? ? ? ? success:function (data) {
nums=data.num;
? ? ? ? ? ? document.getElementById("alreadyget").innerText = nums;
? ? ? ? ? ? document.getElementById("alreadysend").innerText = data.data.sendNum;
? ? ? ? ? ? // document.getElementById("finaltime").innerText = data.msg;
? ? ? ? ? ? if(nums ==$("#times").val() || nums >$("#times").val()){
document.getElementById("finaltime").innerText=getNowFormatDate();
? ? ? ? ? ? ? ? window.clearInterval(stop);
? ? ? ? ? ? ? ? //ajax.abort();
? ? ? ? ? ? }
// alert("執(zhí)行了222");
// setTimeout(function(){$.ajax(getting);},5000)
? ? ? ? },
? ? ? ? error:function () {
alert("出錯");
? ? ? ? }
}
var ajax=function(){$.ajax(getting)};
? ? //window.setInterval(function(){$.ajax(getting)},5000);
? ? var stop=window.setInterval(function(){$.ajax(getting)},5000);
? ? // while(nums == $("#times").val()){
//? ? window.clearInterval(stop);
//? ? ajax.abort();
//? ? $("#alreadypost").click().abort();
// }
});