Scott, take a look at the Wicket framework for an interesting model. It's in Java, so you won't want use it directly, but I think the way that it handles Ajax is really interesting.
Each dynamic part of the code is a component, and is marked with a generated ID. When the user hits a button or link to initiate an action, it initiates a XMLHttpRequest that tells the server what action to perform on what component. Then the server re-renders each affected component and returns new HTML for the updated components, and the Ajax code just replaces the original DOM for those components with the new DOM.
So, the javascript code is very simple - it just sends a request, receives a chunk of HTML, and replaces the existing parts of the DOM tree with the updated parts. That makes the javascript part a very small part of the equation, and all the logic is handled server-side.
by Ian — Aug 03
Each dynamic part of the code is a component, and is marked with a generated ID. When the user hits a button or link to initiate an action, it initiates a XMLHttpRequest that tells the server what action to perform on what component. Then the server re-renders each affected component and returns new HTML for the updated components, and the Ajax code just replaces the original DOM for those components with the new DOM.
So, the javascript code is very simple - it just sends a request, receives a chunk of HTML, and replaces the existing parts of the DOM tree with the updated parts. That makes the javascript part a very small part of the equation, and all the logic is handled server-side.