Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-09
1
Medium Priority
?
270 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 750 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
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…
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)
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…
Suggested Courses

730 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