在asp.net中调用Ajax轮询方法 [英] Ajax polling Method call in asp.net
问题描述
嗨朋友们,
我想ajax轮询调用方法来获取数据。
这是ajax回调,我需要每3秒自动轮询一次电话
$。ajax({
type:POST,
url:Default.aspx / getPak,
data:{},
contentType:application / json; charset = utf-8,
dataType:json ,
成功:函数(msg){
strPak = msg.d;
}
});
Code首次正常运行。但我想以一定的间隔打电话,比如3秒钟。
我们将非常感谢您的帮助。
提前致谢。
注意:我试过
setInterval(location.reload();,3000);
但是我想要优化的ajax调用; - )
.ajax({
type:POST,
url:Default.aspx / getPak,
data:{} ,
contentType:application / json; charset = utf-8,
dataType:json,
success:function(msg){
strPak = msg.d ;
}
});
Code首次正常运行。但我想以一定的间隔打电话,比如3秒钟。
我们将非常感谢您的帮助。
提前致谢。
注意:我试过setInterval(location.reload();,3000);但我想要优化的ajax调用; - )
查看这篇文章:
如何对实施-AJAX的基于轮询 - 在-ASP-NET-MVC
Hi Friends,
I want to ajax poll the call to method to get data.
This is the ajax call back, I need to auto poll the call for every 3 secs
$.ajax({ type: "POST", url: "Default.aspx/getPak", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { strPak = msg.d; } });
Code works fine for first time. But I want to call at certain intervals like 3 secs or something.
Your help will be appreciated.
Thanks in advance.
Note: I tried
setInterval("location.reload();", 3000);
But I want optimized ajax call ;-)
.ajax({ type: "POST", url: "Default.aspx/getPak", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { strPak = msg.d; } });
Code works fine for first time. But I want to call at certain intervals like 3 secs or something.
Your help will be appreciated.
Thanks in advance.
Note: I triedsetInterval("location.reload();", 3000);But I want optimized ajax call ;-)
Check this post out:
How-to-implement-AJAX-based-polling-in-ASP-NET-MVC
这篇关于在asp.net中调用Ajax轮询方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!