在asp.net中调用Ajax轮询方法 [英] Ajax polling Method call in asp.net

查看:115
本文介绍了在asp.net中调用Ajax轮询方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我想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 tried

setInterval("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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆