Solved

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

Posted on 2009-05-09
1
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article discusses how to implement server side field validation and display customized error messages to the client.
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)

635 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