52,800
社区成员
发帖
与我相关
我的任务
分享
function getMessage (data) {
var num1 = Math.round(Math.random()*10000000);
var num = num1.toString().substr(0, 4);
var json = '{"sec":' + sec + ',"usec":' + usec + ',"toSec":' + toSec + ',"toUsec":' + toUsec + '}';
var param = "?JSON=" + json + "&type=getMessage" + "&rand=" + num;
$.ajax({ cache: false
, type: "GET"
, url: url + param
, dataType: "json"
, timeout : 20000
//, data: {"JSON" : json , "type": "getMessage", "rand": num}
, error: function (XMLHttpRequest, textStatus, errorThrown) {
if (textStatus == "timeout") {
getMessage(json);
}
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
, success: function (data) {
if (data.type == "getMessage") {
//$("#message").append("hello world" + "
");
$("#message").append(data.message + "
");
getMessage(json);
}
if (data.type == "noMessage") {
getMessage(json);
}
}
});
}