我正在使用jQuery AJAX调用JSON服务。然后我将数据吐出到.html。我想要2件事情发生。 1.我想刷新按钮来刷新数据,而不是整个页面。 2.我想每隔5分钟左右更新一次setTimeout或setInterval(哪个效果最好)。但刷新页面。 如何将AJAX包装在setTimeout或setInterval中,或每隔5分钟左右使用按钮和计时器刷新数据。我知道这应该很简单,但我一直没有能够得到它的工作。提前致谢。jQuery Ajax setTimeout JSON
以下是我的代码。
$.ajax({
type: "POST",
url: "/myservice.asmx/WebMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var myval = msg.d;
// $('#jsonstring').html(myval);
var obj = jQuery.parseJSON(myval);
$('#Data1').html(obj.DataOne);
$('#Data2').html(obj.DataTwo);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.statusText);
alert(xhr.responseText);
alert(xhr.status);
alert(thrownError);
}
});
没关系我想通了自动重装,并点击该按钮对不起无关的问题 – ClosDesign