开发者

how to call this calling WCF method continuously

I have an ajax enabled WCF service method :

[OperationContract] public string Test(string name) { return "testing testing." + name; }

and I am calling it with following code:

$(document)开发者_JAVA技巧.ready(function () { var varData = $("#NewSkill").val();

$("#Button1").click(function () {

            $.ajax({
                type: "POST",
                url: "TimeService.svc/Test",
                data: '{"name" : "John"}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    alert(msg.d);
                } 
            });
        });
    });

I want to call this method continuously after every 5 seconds using above code . How can I do this ?


Move the $.ajax(); part to a Javascript function say AjaxCall(). Create a javascript variable

var isActivated = false;

$(document).ready(function () { while(isActivated){ setTimeout("AjaxCall()",3000); } } );

$("#Button1").click(isActivated = true)

Hope this helsps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜