Jump to content

Retrieving data from server


ueon

Recommended Posts

If a user has loaded a website, and doesn't click on anything. However, if an administrator changes a value on the server that affects the page the user is on, does the user see the change immediately or after a refresh?

 

this is an php/ajax website

Link to comment
Share on other sites

The way browsers work is defined by the HTTP protocol.  At its most simple, it's a request/response system.  Browser requests page ->  Server replies with response.  This happens as quickly as possible, and as soon as the last bit is sent the server closes the socket connection, at least in a logical sense.

 

Page requests occur in response to user activity (entering a url, clicking on a button or link) and by design there is no sustained connection or session possible.  Cookies were the first attempt to provide a mechanism to get around this lack of session.

 

At the point that a page has been delivered based on information pulled from a database, that information is inherently old.  If one second later someone changes the database, there is no way that will reflected in the static html page I'm looking at in my browser.

 

Ajax is a fancy name for what is a simply facility that was added to javascript (originally by microsoft) allowing it to make connections from the browser to the server using javascript code.  So you can set up a connection to sit and poll fairly frequently, and in that case, you would be able to detect that data had changed and update the screen via javascript.  There is also a technique people call "long polling" that takes a slightly different approach and in some cases is a better solution than frequent polling.

 

This does a great job explaining it:  http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.