views:

59

answers:

3

Hello,

I just wondered if there is any existing framework or someone has experiences with using entirely static HTML templates that get filled with data provided via JSON from the server.

The HTML pages with JavaScript support should fulfill the role of the View whereas Controller and Model are handled by the PHP on the server side.

Views would the query via JSON-RPC or similar data from the Model and then render the results by manipulating the DOM.

I pretty much like this idea, it came into my mind weeks ago but I never found something on the web experiences with that or even already existing framework.

But maybe I am just a noob at googling?

Maybe one of you can help me out here.

Thanks in advance Have a nice day!

Benjamin

A: 

That's pretty much how Google do a lot of their stuff - do a view source on Gmail to see how much data they return in the HTML.

It's called Ajax. (That's not meant to sound too sarcastic - Ajax doesn't necessarily work like this, but ajax-based apps will do a lot of the rendering logic via JavaScript rather than via server-side code.)

Skilldrick
Thanks, problem is that the code on gmail is compressed and very hard to read because of that.Yeah sure I am aware of AJAX but I never found something that describes a whole webpage that is only AJAX-driven.I plan to write applications that only communicate via JSON with the webserver to generate the lowest possible traffic while being very dynamic and I think that could be a cool approach for that.
Benjamin
I believe Gmail was written with Closure (as well as Google Reader). See my comment on the question for more info.
Nate Bundy
@Gordon No, Google's Closure Tools (http://code.google.com/closure/), as opposed to the Clojure (http://clojure.org/) language which is a dialect of Lisp and compiles to JVM bytecode.
Nate Bundy
A: 

This is very much possible and often found with Rich Client Applications. The first call to the application delivers the initial UI with any behavior defined in JavaScript files. Any further interaction is done via Ajax.

For the serverside, have a look at

though this could just as well be a regular MVC application too. A Json or XML Response can still be considered a View. It's up to you to code your controllers to return appropriate data.

Gordon
Thanks for those links. I love Zend Framework and will have a look into that :)
Benjamin
A: 

You need a framework that doesn't limit you to any specific way of handling the view component of your MVC application and I think Zend Framework would be your best choice. It also has a great integration with DOJO and that makes it a lot easier to achieve what you need.

Cg Alive