Solved

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

Posted on 2009-05-09
1
237 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
ID: 24343980
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

829 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