AJAX Question

K

KDawg44

Hello,

I am beginning to work on a project for my degree. The concept is
"The Utilization of AJAX calls to separate the Presentation Layer and
Application Layer in Web Applications."

Now, I am developing in PHP as my server side scripting but am try to
decide how to approach this problem. To adequately support this
concept, should I have no server side scripting at all on the accessed
pages? (no php except in the calls by AJAX).

Another question would be when I get the data back from the call, is
there a way to pass it into some PHP?

Thanks, I am at the early stages and am trying to get this kicked
off.

Kevin
 
P

Peter Michaux

Hello,

I am beginning to work on a project for my degree. The concept is
"The Utilization of AJAX calls to separate the Presentation Layer and
Application Layer in Web Applications."

Now, I am developing in PHP as my server side scripting but am try to
decide how to approach this problem. To adequately support this
concept, should I have no server side scripting at all on the accessed
pages? (no php except in the calls by AJAX).

Another question would be when I get the data back from the call, is
there a way to pass it into some PHP?

Thanks, I am at the early stages and am trying to get this kicked
off.

It is difficult to design something well without knowing what the goal
is exactly. I've asked similarly vague questions in here before and,
to my recollection, there was little discussion. What is the web
application you are building as your example? Is the objective to
build this application with a predefined architecture in mind or to
use whichever architecture best suits the web realities of today? The
former is a very academic approach while the later is more likely what
one would need to do to satisfy the widest group of real world users.

Peter
 
K

KDawg44

It is difficult to design something well without knowing what the goal
is exactly. I've asked similarly vague questions in here before and,
to my recollection, there was little discussion. What is the web
application you are building as your example? Is the objective to
build this application with a predefined architecture in mind or to
use whichever architecture best suits the web realities of today? The
former is a very academic approach while the later is more likely what
one would need to do to satisfy the widest group of real world users.

Peter

The application that is the example for the concept is a diet tracking
system that allows users to input the food/beverages they intake in
meals and tracks the amount of calories, fat, carbs, vitamins, etc
that they take in on a daily basis.

I understand that my questions are vague, as the approach is still a
little unclear in my head. I am hoping to get feed back on how
developers feel on the topic. My feeling is that any data
manipulation or data accessed from the database should be done
separately and then handed back through an AJAX call to my PHP
scripts, however, something that is all Presentation related (such as
echoing the data to the screen using PHP (though that may be a bad
example due to the fact that this can be achieved with JavaScript).

Thanks for any suggestions, opinions, or advice.

Kevin
 
P

Peter Michaux

[snip]
The application that is the example for the concept is a diet tracking
system that allows users to input the food/beverages they intake in
meals and tracks the amount of calories, fat, carbs, vitamins, etc
that they take in on a daily basis.

This is a basic CRUD-type application and there is no question that
this can be done without using any client-side scripting. The client-
side scripting can be used to enhance the user experience when client-
side feature testing shows that the features needed for the
enhancements are available. This is a concept called "progressive
enhancements" (or perhaps better known as but a worse name "graceful
degradation".)

I understand that my questions are vague, as the approach is still a
little unclear in my head. I am hoping to get feed back on how
developers feel on the topic. My feeling is that any data
manipulation or data accessed from the database should be done
separately and then handed back through an AJAX call to my PHP
scripts, however, something that is all Presentation related (such as
echoing the data to the screen using PHP (though that may be a bad
example due to the fact that this can be achieved with JavaScript).

That paragraph is a little unclear to me. I understand you might be
trying to have all presentation done in the browser and the server
more-or-less as a data validator and data store. Architecturally, this
is a nice idea and there are web sites built like this; however, this
is not really either the intention of how the web was to be used
(sharing documents) or the way to reach the broadest audience (i.e.
those with JavaScript disabled or insufficient JavaScript support for
what your client-side application requires.)

If you are willing to say "this application only works with Internet
Explorer 6+, FireFox 2+, Opera 9+, Safari 2+ with images, CSS,
JavaScript, cookies all enabled and ActiveX enabled on IE6" then you
can build an application that has presentation performed only on the
client-side. These requirements are quite restrictive (e.g. thinking
about some disabled users or users with slightly older cell phones)
and since this application could be built without any of these
requirements (i.e. this application could be written to work with IE4,
Netscape Navigator 4 with JavaScript disabled, for example), then why
shouldn't it be written that way? Then progressive enhancements can be
used to make the user experience "slicker."

If your example was a web-based chat application then perhaps
requiring JavaScript would be mandatory and the decisions about how to
design the application would likely be completely different. It
matters what you are building before you decide how you will build it
and which technologies will be required for functionality.

Peter
 
K

KDawg44

[snip]
The application that is the example for the concept is a diet tracking
system that allows users to input the food/beverages they intake in
meals and tracks the amount of calories, fat, carbs, vitamins, etc
that they take in on a daily basis.

This is a basic CRUD-type application and there is no question that
this can be done without using any client-side scripting. The client-
side scripting can be used to enhance the user experience when client-
side feature testing shows that the features needed for the
enhancements are available. This is a concept called "progressive
enhancements" (or perhaps better known as but a worse name "graceful
degradation".)
I understand that my questions are vague, as the approach is still a
little unclear in my head.  I am hoping to get feed back on how
developers feel on the topic.  My feeling is that any data
manipulation or data accessed from the database should be done
separately and then handed back through an AJAX call to my PHP
scripts, however, something that is all Presentation related (such as
echoing the data to the screen using PHP (though that may be a bad
example due to the fact that this can be achieved with JavaScript).

That paragraph is a little unclear to me. I understand you might be
trying to have all presentation done in the browser and the server
more-or-less as a data validator and data store. Architecturally, this
is a nice idea and there are web sites built like this; however, this
is not really either the intention of how the web was to be used
(sharing documents) or the way to reach the broadest audience (i.e.
those with JavaScript disabled or insufficient JavaScript support for
what your client-side application requires.)

If you are willing to say "this application only works with Internet
Explorer 6+, FireFox 2+, Opera 9+, Safari 2+ with images, CSS,
JavaScript, cookies all enabled and ActiveX enabled on IE6" then you
can build an application that has presentation performed only on the
client-side. These requirements are quite restrictive (e.g. thinking
about some disabled users or users with slightly older cell phones)
and since this application could be built without any of these
requirements (i.e. this application could be written to work with IE4,
Netscape Navigator 4 with JavaScript disabled, for example), then why
shouldn't it be written that way? Then progressive enhancements can be
used to make the user experience "slicker."

If your example was a web-based chat application then perhaps
requiring JavaScript would be mandatory and the decisions about how to
design the application would likely be completely different. It
matters what you are building before you decide how you will build it
and which technologies will be required for functionality.

Peter

I understand and appreciate all your points. However, the point of
this project is to achieve a separation of the layers in the web app,
making use of AJAX calls.

Thanks,

Kevin
 
P

Peter Michaux

[snip]
I understand and appreciate all your points. However, the point of
this project is to achieve a separation of the layers in the web app,
making use of AJAX calls.

That is fine as those restrictions are justified up front and
potential costs and/or benefits to business are acknowledged. Benefits
include speed of development.

Building such an application is pretty easy. Start with a document
with an empty body like this


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Diet Tracking App</title>
<link href="/css/app.css" rel="stylesheet" type="text/css">
<script src="/js/app.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

Use XMLHttpRequest with JSON for all communication with the server.
You might want to use an MVC-like framework for the client-side code.

Good luck.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top