473,608 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP & AJAX

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
Jan 17 '08 #1
4 2045
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.
js*******@attgl obal.net
=============== ===

Jan 18 '08 #2
KDawg44 wrote:
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?
Yes, you may persist objects in $_SESSION.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 18 days, 10:00.]

Ham vs Bacon vs Pork
http://tobyinkster.co.uk/blog/2008/01/17/pork-etc/
Jan 18 '08 #3
On Jan 17, 7:14 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
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.
jstuck...@attgl obal.net
=============== ===
Jerry,

Thanks so much for your responses. You are always such a helpful
resource. I understand OO programming but as a young professional
(whose mainstay is sys admin and network engineering and not
programming) unfortunately putting it into practice with databases is
something i have not really done and using OO concepts in web
programming I have not done at all.

So the best bet, if I understand you clearly, is to create a hash
table with a key and some data (whatever the primary key in the DB is
maybe?) that allows me to quickly pull that data from the DB again and
load it back in to the PHP object?

Thanks for the help.
Jan 18 '08 #4
KDawg44 wrote:
On Jan 17, 7:14 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>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.
jstuck...@attg lobal.net
============== ====

Jerry,

Thanks so much for your responses. You are always such a helpful
resource. I understand OO programming but as a young professional
(whose mainstay is sys admin and network engineering and not
programming) unfortunately putting it into practice with databases is
something i have not really done and using OO concepts in web
programming I have not done at all.

So the best bet, if I understand you clearly, is to create a hash
table with a key and some data (whatever the primary key in the DB is
maybe?) that allows me to quickly pull that data from the DB again and
load it back in to the PHP object?

Thanks for the help.
That's what I generally do. But no need to create a hash value. Each
table should already have a primary key (typically an automatically
numbered column) which is all you need to identify the data. Just pass
that in the $_SESSION, i.e. as $_SESSION['datakey'];

Transactional programming is quite a bit different from what most
programmers are used to.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jan 18 '08 #5

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

Similar topics

4
9549
by: k.mitz | last post by:
Hi, I have a PHP application that allows users to generate a .pdf report of their database content. Normally, I've had to refresh a page to call the script to generate the report, so there's a second or so when the browser goes blank. I was wondering if it was possible to use AJAX to call the script to generate the report, then begin the download without refreshing the page (or in the case of I.E., leaving me with a blank window that...
21
6124
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
10
6302
by: Steve | last post by:
I need to build a very dynamic client and would be interested in knowing the pros and cons of using JSF and Ajax to accomplish this. Thanks. Steve
13
1712
by: Sharon | last post by:
Hi all, I was wondering if anyone had experience using ajax with asp.net controls. What i'm looking for, are ways to implement and possible problems. A way to implement could be rendering the control on the server side, and send the html string back to javascript. A possible problem is the control post back behavior and control view state usage. Thanks, Sharon.
3
1616
by: Ivan P | last post by:
Hello! I have a index.php that on one click calls via AJAX a file.php. index.php looks like this: <html > <head> <script language="javascript" type="text/javascript" >
0
5556
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
2
1334
by: =?Utf-8?B?RG90TmV0RGV2?= | last post by:
Hi, We are still using .net 1.1 and I am working on a problem that I thought could be 'probably' done easily through 'AJAX'. I visited the ajax.asp.net site and I got an impression that its only for .net 2.0. Can any one point me to resources for using AJAX with asp.net 1.1? Thnx
18
2376
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not that great. One of the cons of ASP & Javascript is that they're both interpreted, which means one has twice the amount of work to do interms of syntax checking & semantic/runtime checking. Another bad thing is that ASP & Javascript doesn't have...
0
7178
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along the way. First, deep linking is not something that a completely AJAX web site should be able to do by it's very nature of everything being on one page basically. So how can a person deep link to something that is on one page? This question...
0
8495
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
8470
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
8330
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
6815
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
6011
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
5475
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();...
1
2474
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
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
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.