View Full Version : 2-tier or N-tier on client side?

18 Dec 2006, 10:41 PM
Usually we choose a 3-tier or N-tier structure for database driven website developement. With AJAX, do we need a 2-tier or N-tier on client side?

For example, I usually use data model (DM) in js for grid, view, content panel. The js code for DM is usually mixed with other UI interface in one class. How can I effectively have a seperate class, for example datamodel class, which is exclusive for data access? In this way the DM code can be reused in many pages.

I am a newbie in ajax application developement. All of the time I need your guys help!

Thank you!

19 Dec 2006, 1:26 PM
Extending the appropriate data model class always an option. Then you can add additional helper functions as well. For example:

FeedDataModel = function(){
var schema =
... // put your data model init and config stuff here
// you can optionally pass paging init info to this
// objects constructor and call initPaging with it
YAHOO.extendX(FeedDataModel, YAHOO.ext.grid.XMLDataModel, {
loadFeed : function(feedUrl){
this.load('feed-proxy.php', {feed: feedUrl});

then anywhere you need a new data model for feeds:

var dm = new FeedDataModel();