473,748 Members | 4,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax Asynchronous refresh. Is it possible ?

Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my
web server. The refresh action should be taken only when something
really happens that makes sense

Is it possible ?

greets, peter
Aug 23 '07 #1
10 3156
I dont think that is possible, you cant "notify" a web browser client that
something has changed on the server. That is the nature of web sites and web
applications, they are "stateless" .

"Piotr Nowak" wrote:
Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my
web server. The refresh action should be taken only when something
really happens that makes sense

Is it possible ?

greets, peter
Aug 23 '07 #2
NH pisze:
I dont think that is possible, you cant "notify" a web browser client that
something has changed on the server. That is the nature of web sites and web
applications, they are "stateless" .

"Piotr Nowak" wrote:
>Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my
web server. The refresh action should be taken only when something
really happens that makes sense

Is it possible ?

greets, peter
stateless means that theres no information about previous request in the
new one, its forgotten.
i just want to get one simple response right from the server when
something happens to update my client browser view.
Aug 23 '07 #3
As long as there is some asp.net code you can run that will return a true or
false as to the server being updated then this is possible. Use an ajax
call every x seconds and when it returns true issue a page reload via
javascript.

"Piotr Nowak" <p.******@STRIP THISwasko.plwro te in message
news:fa******** **@atlantis.new s.tpi.pl...
Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my web
server. The refresh action should be taken only when something really
happens that makes sense

Is it possible ?

greets, peter

Aug 23 '07 #4
Aidy pisze:
As long as there is some asp.net code you can run that will return a true or
false as to the server being updated then this is possible. Use an ajax
call every x seconds and when it returns true issue a page reload via
javascript.

"Piotr Nowak" <p.******@STRIP THISwasko.plwro te in message
news:fa******** **@atlantis.new s.tpi.pl...
>Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my web
server. The refresh action should be taken only when something really
happens that makes sense

Is it possible ?

greets, peter

yes, but the page reload is not as much impact as server side actions
because every x second i would have to do a database hit to check if
something changed, then do a page refresh.
im not shure if i was enough clear..
Aug 23 '07 #5
yes, but the page reload is not as much impact as server side actions
because every x second i would have to do a database hit to check if
something changed, then do a page refresh.
im not shure if i was enough clear..
It's hard to advise on solutions without knowing more about how it can be
determined when a refresh is needed. You say;

"i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it."

Could your process do something like create/update a file saying to refresh,
your ajax call will see if the data in the file indicates a refresh is
needed. If it is then the call will return that and update the file to set
it back to no refresh being needed. That way every x seconds you are merely
accessing the file system and not the database.
Aug 23 '07 #6
No the server can't reach a web client. This is always the client that sends
a request to the server and the server only responds to incoming requests.

You could issue an AJAX call to the server that just tell if the client
should be updated. If not you have nothing more to do, if yes you can issue
your more complex ajax calls that would update parts of your pages...

Youn may want to explain a bit more what you are trying to do...
--
Patrice

"Piotr Nowak" <p.******@STRIP THISwasko.pla écrit dans le message de news:
fa**********@at lantis.news.tpi .pl...
Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my web
server. The refresh action should be taken only when something really
happens that makes sense

Is it possible ?

greets, peter

Aug 23 '07 #7
Patrice pisze:
No the server can't reach a web client. This is always the client that sends
a request to the server and the server only responds to incoming requests.

You could issue an AJAX call to the server that just tell if the client
should be updated. If not you have nothing more to do, if yes you can issue
your more complex ajax calls that would update parts of your pages...

Youn may want to explain a bit more what you are trying to do...
--
Patrice

"Piotr Nowak" <p.******@STRIP THISwasko.pla écrit dans le message de news:
fa**********@at lantis.news.tpi .pl...
>Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my web
server. The refresh action should be taken only when something really
happens that makes sense

Is it possible ?

greets, peter

Sure its quite generic problem.

Imagine you develop a online game, like ogame.
There's a lot action behind the scenes, players are making some actions
that take some time (training soldiers, building houses) which takes
some time (minutes, hours, even days). after time is up and soldier,
building is finished a browser should be refreshed to say - 'hey, your
request is done now !, you succesfully trained 5 soldiers and built one
house'.

So, it doesnt make sense to poll every 5 seconds if action of building a
house last 2 days ! Divide 2days by 5 seconds and you get number of
waisted requests to check if action is done.

was this enough clear for You ?

best regards

Aug 23 '07 #8
My first idea would be then to avoid polling at a particular fixed interval.
For example the AJAX call could return the next action with an estimated
time to complete (if 0 you can then can then perform the actual action). You
can now use this information to schedule your next AJAX call. If the user
does some action, you'll issue this call again (in case the new action would
be earlier than the previous one) etc...

In some cases the browser is just used to download a software especially if
a quick multiple players interaction is needed...

---
Patrice

"Piotr Nowak" <p.******@STRIP THISwasko.pla écrit dans le message de news:
fa**********@ne mesis.news.tpi. pl...
Patrice pisze:
>No the server can't reach a web client. This is always the client that
sends a request to the server and the server only responds to incoming
requests.

You could issue an AJAX call to the server that just tell if the client
should be updated. If not you have nothing more to do, if yes you can
issue your more complex ajax calls that would update parts of your
pages...

Youn may want to explain a bit more what you are trying to do...
--
Patrice

"Piotr Nowak" <p.******@STRIP THISwasko.pla écrit dans le message de
news: fa**********@at lantis.news.tpi .pl...
>>Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig
it.

I do not want to refresh my page i.e. every 5 seconds, i just want to
refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my
web server. The refresh action should be taken only when something
really happens that makes sense

Is it possible ?

greets, peter

Sure its quite generic problem.

Imagine you develop a online game, like ogame.
There's a lot action behind the scenes, players are making some actions
that take some time (training soldiers, building houses) which takes some
time (minutes, hours, even days). after time is up and soldier, building
is finished a browser should be refreshed to say - 'hey, your request is
done now !, you succesfully trained 5 soldiers and built one house'.

So, it doesnt make sense to poll every 5 seconds if action of building a
house last 2 days ! Divide 2days by 5 seconds and you get number of
waisted requests to check if action is done.

was this enough clear for You ?

best regards

Aug 23 '07 #9
Thanks, i have been thinking quite the same - time estimation.

regards
Aug 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2157
by: JM | last post by:
Hi, I transferred an AJAX application to the server to be used across the Internet. On my localhost, it works great. But when I transferred it to the server, the user control freezes for a second or two whenever it calls the AJAX method, including the textbox where the user inputs the chat message. All it does is retrieve new messages from the server every second. Please help if you have any idea to how to make the textbox run smoothly,...
23
2028
by: ivan | last post by:
AJAX is a stupid and confusing word. People is wondering for something that programmers have used for many years. Javascript + Xml and asynchronous requests is not new. People started to speak about AJAX a lot after XmlHttpRequest was introduced, so AJAX cant'be Javasript+xml+xmlhttprequest. But if you still think so, you can't anyway call this AJAX. What is new with xmlhttprequest is the possibility to perform a synchronous request! (but...
17
13208
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
31
3158
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked around here? If so, do you know if Ajax.NET can be used without prototype.js? -- "The most convoluted explanation that fits all of the made-up facts is the most likely to be believed by conspiracy theorists. Fitting the
5
8131
by: Danny R | last post by:
I have the following javascript which works in either IE or Firefox but not on both. When I set the code to http_request.open('POST', url, true) - Works in IE only http_request.open('GET', url, true) - Works in Firefox only; Does not refresh in IE. How do I resolve this?
3
1730
by: Erik Cruz | last post by:
Hi. I will start to migrate an asp.net 1.1 application to 2.0. This application uses an Iframe that simply calls a method to update a field on my databse every minute. In order to do this, I actually do a page refresh that runs my method on the server side. how can I do this using Visual Studio 2005 and Ajax? I do not need to update the interface, I just need to update the database. Regards,
25
2548
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
29
3319
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to use it in sync mode. Any ideas what can I do? Thanks, Zalek.
29
3908
Frinavale
by: Frinavale | last post by:
I have 2 FireFox (version 2) browser windows opened. One is the child of the other. When the user is finished with the child window, a method in the parent window is called to refresh a section of the page. This is the JavaScript code that I'm using to refresh the content in the parent page: <script type="text/javascript"> function UpdateList() {
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.