|
Posted by Jerry Stuckle on 01/18/08 00:14
KDawg44 wrote:
> Hi,
>
> I have a feeling this is a dumb question, but I am exploring AJAX and
> PHP. I would like to write my PHP in an Object Oriented approach.
> What is the limitation on what I can return in AJAX? Every example I
> find seems to be text, which make sense because it is client side.
> So, if I want to try to separate the presentation from the
> application, I should call a PHP script using AJAX, and in that PHP
> script have objects, call the objects methods and which return to the
> PHP script, which returns it to the AJAX script.
>
> So, how do I keep persistent objects throughout the application? Will
> each PHP call instantiate a new session or new version of the PHP
> script or can I simply put the objects in the $_SESSION?
>
> Thanks for your help as I try to learn/understand this.
>
> Kevin
>
Kevin,
Web pages are transaction oriented. Every call to a web page, whether
it be via AJAX or a browser request, is a new transaction, and has
nothing in it other than what the browser sends.
Typically in web programming, you do not keep persistent objects
throughout the run. Rather, you create them as needed.
Two ways to keep track of things - store things in a cookie (typically
small amounts of text data on the browser) or in the session (text or
binary data). But either way, you don't want to store large amounts of
data, for performance reasons.
You can put objects in the session, as long as they don't contain
resources. But if there is a large amount of data, i.e. from a
database, it's generally better to keep a key in the session and
retrieve the data when it is required.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|