Solved

how to send update client browser at regualr interval using asp.net and jquery

Posted on 2009-05-09
1
206 Views
Last Modified: 2012-05-06
I have a web page and this contains a button, if user clicks on this button then I have to run a process a long time taking task.

now i am planning to use using asyn handler or asyn page to do this task.
but what i need to send text string at regular interval to the client about the process say after every 5 sec I need to send a update text.

is it possible to do so?
0
Comment
Question by:ziorrinfotech
1 Comment
 
LVL 12

Accepted Solution

by:
alien109 earned 250 total points
Comment Utility
using setInterval, you can continuously execute a function. it's hard to provide sample code, without knowing more, but essentially you could do something like this -

function pollServer() {
    $.get(...., function(response) {
        // response from server should contain update text or
        // a flag to indicate if we should stop polling...

        // if we send back a flag to signal the task is complete...
        if(response... == "complete")
        {
                //stop polling the server
                clearInterval(intervalId);
        }
    })
}

var intervalId = setInterval(pollServer, 5000);

create a function that polls the server, then start calling that function on an interval, storing a reference to the interval's id so that we can stop it later.

in side of the polling function we use jquery to call the server and get a response. based on what is returned (and how it is returned) we can then determine if we should stop executing the polling function or display a message...
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now