Hello,
What's the best way to add dynamic content to a web page after a successfull xml http request. To break down a more concrete example:
- User fills in data in input field (e.g. a forum post)
- Data is asynchrously updated using the ajax technology
- The forum post is instantly displayed for the end user
Sites like Facebook or last.fm (when you post a shout, ie) send the processed markup in a direct object back to the javascript, instead of just the processed data. An example of this written in jQuery would be
$('#activeField').html(callback.data);
Another way to do this is to create the dom elements on the fly with javascript. I find this too clumsy as there's no easy (?) and simple way of doing this today. At the same time, sending the processed markup directly from the server violates our application's design principles (MVC), as having markup in a front controller is not preferred.
What's the "best practices" way of doing this? Thanks!