To obtain the effect, two components must be considered: the server side and the client side.
On the server side goes code that produces a fragment of HTML. On the client side a placeholder is
needed in the page for the requested data that is usually a simple div element with a proper id and
some code to make the request and manage the response. Neko is used for the generation of the web
services on the server; although highly recommended, this is not the only possible way to proceed.
Experienced programmers can use other server side languages to provide the same functionalities.
416
Part II: Server Side, JavaScript, and Flash: Oh My!
Updating a Panel Content Using AJAX
In the following example, a page contains an empty div element with id quotation . Once the page is
loaded the client makes a second request to the server to obtain a random quotation and puts the
response inside the placeholder element. There can be many reasons why the quotation is not served
directly in the page: It can come from a different service, the panel can be updated several times during
the page lifetime, or it is possible to introduce interaction with the user that can request a new quotation
on the click of a button.
Pages:
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785