Jump to content

Retrieving data from server


ueon

Recommended Posts

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/

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.