473,597 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax asynchronous 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
25 2535
Hi Piotr,

yes, this is possible. Read here how to get more information about it:
http://catb.org/~esr/faqs/smart-questions.html

Best regards,
Jan

Piotr Nowak wrote:
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.
Is it possible ?
--
_______________ _______________ _______________ _______________ _____________
insOMnia - We never sleep...
http://www.insOMnia-hq.de
Aug 23 '07 #2
Jan Thomä pisze:
Hi Piotr,

yes, this is possible. Read here how to get more information about it:
http://catb.org/~esr/faqs/smart-questions.html

Best regards,
Jan

Piotr Nowak wrote:
>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.
Is it possible ?
you post a site how to ask questions wisely, it doesnt help me much, sorry.
Aug 23 '07 #3
It will. In time.

Best regards,
Jan

Piotr Nowak wrote:
Jan Thomä pisze:
>Hi Piotr,

yes, this is possible. Read here how to get more information about it:
http://catb.org/~esr/faqs/smart-questions.html

Best regards,
Jan

Piotr Nowak wrote:
>>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. Is it possible ?

you post a site how to ask questions wisely, it doesnt help me much,
sorry.
--
_______________ _______________ _______________ _______________ _____________
insOMnia - We never sleep...
http://www.insOMnia-hq.de
Aug 23 '07 #4
Jan Thomä pisze:
It will. In time.

Best regards,
Jan

Piotr Nowak wrote:
>Jan Thomä pisze:
>>Hi Piotr,

yes, this is possible. Read here how to get more information about it:
http://catb.org/~esr/faqs/smart-questions.html

Best regards,
Jan

Piotr Nowak wrote:

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. Is it possible ?
you post a site how to ask questions wisely, it doesnt help me much,
sorry.
if i wasn't searching on google i wouldn't have asked here.
im here because i didnt found solution anywhere else, so i want You,
experts to say what you think about it.
Aug 23 '07 #5
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
Hi Peter,

This question is more javascript oriented than PHP.
Ajax could be a nice solution. But that only works when visitors have it
enabled of course. I hear different numbers, but around 10% of the
people have it disabled. In that case AJAX won't work of course.

In short:
1) Let the browser make a xmlhttprequest object.
Beware that different browsers need different approach.
Read up here: http://www.w3schools.com/ajax

2) Make a simple php script that your ajax code calls.
Let it return something like: REFRESH or NOREFRESH

3) In case of refresh: refresh. ;-)

Note: Make sure that the PHPscript that returns REFRESH or NOREFRESH is
a simple one. You don't want 10.000 browsers poll your server every 5
seconds...

But one thing: WHY do you want this behaviour? Doesn't everybody know
that a page that is untouched on the browserscreen for 20 hours may be
stale?

Regards,
Erwin Moller
Aug 23 '07 #6
Okay,

before this gets out of hand... My intention is to teach fishing instead of
giving fish. Your question was "Is it possible?" The answer to that
question is "Yes, it is possible.". I have sent you link about asking smart
questions to help you solve your problem. I did not imply that you should
use Google, I'd like you to specify your issue in a way that enables anyone
to help you.

Because currently no one knows, what is your problem. What have you tried so
far? What is the issue you are encountering? Do you need information about
how Ajax is working, or do you need a way to make the database send out
notifications, or what else do you need? What is this data, what triggers
the change? What would you deem as "something interesting is happening"? So
how do you expect to get answers without giving that information? Don't
expect others to ask the right questions for you, ask them yourself. This
is about being helped with a problem not about getting an out of the box
solution. No one will do the homework for you. In that sense, please try
again and take your time to ask a better question and then come back again.

Best regards,
Jan

Piotr Nowak wrote:
if i wasn't searching on google i wouldn't have asked here.
im here because i didnt found solution anywhere else, so i want You,
experts to say what you think about it.
--
_______________ _______________ _______________ _______________ _____________
insOMnia - We never sleep...
http://www.insOMnia-hq.de
Aug 23 '07 #7
Piotr Nowak pisze:
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
Let me put it in another way, to help you understand my 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 ?
Aug 23 '07 #8
On 23.08.2007 11:11 Jan Thomä wrote:
Okay,
[snip]
Best regards,
Jan

Piotr Nowak wrote:
>if i wasn't searching on google i wouldn't have asked here.
im here because i didnt found solution anywhere else, so i want You,
experts to say what you think about it.
Please do not top-post.
--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Aug 23 '07 #9
On 23.08.2007 09:58 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 ?
Yes, it's possible in http, however I think you'd be better off with
flash or java applet connected to a non-http socket server.

The correct search term for what you're trying to do is "server push",
hope this helps you further.
--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Aug 23 '07 #10

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

Similar topics

4
4305
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but from within an inline function. Within the AJAX object: this.xmlhttp = new XMLHttpRequest(); this.response = ''; //to contain the response text OR xml var that = this; //since we cannot reference this within the
7
2145
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
2018
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...
31
3102
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
2210
by: Kursat | last post by:
Hi, I want to add new collapsable panel items using java script at client side. Is this possible to create Ajax components like collapsable panel without server round trip? Thanks in advance.
17
11856
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);" onclick="show('ajaxrequest.php?action=removefield','div1');show('ajaxrequest.php?action=reloaddiv2','div2')">verwijderen</a> While both seperate actions work they dont when I put them together. Anyone know how to fix this ? My ajax.js with funcition show
10
3145
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
3298
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.
6
7940
by: sheldonlg | last post by:
I came across a problem and googling for an answer didn't help. What I want to do is run an AJAX script that sets a hidden variable on the form. I call the AJAX script from a javascript function. After the call, I check the value of that hidden variable and proceed according to whether it is zero or one. The problem is that the AJAX call does not complete before the test. So, I put in a delay after the call to the AJAX function. I...
0
8276
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...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8261
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6705
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
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
5437
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
3936
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.