[eluser]Randy Casburn[/eluser]
OK...I get you...
Sorry about the tangent about the cache...I just didn't know where you were experience wise ;-)
No, I don't use that method at all. This is one of the shortcomings IMHO of our environment. Sometimes we forget that we have an entire architecture to draw from and we try to rely on the wrong parts to do the wrong jobs (again, IMHO).
You have client with a very powerful scripting language that can manipulate the daylights out of the DOM. Why would you come all the way back to the server, go through all the overhead of the HTML construction process by CI to create and recreate these posts? You are absolutely correct in your thinking that this is crazy.
So now our thoughts have finally converged and I've caught up with you ;-) ...
This is how I do what you want to do:
1) I us JavaScript to manipulate the DOM by creating new DOM element (<div> <span> whatever) tags that appropriate for the structure of the content that will be returned from my XMLHttpRequest. I send the
2) I send the XMLHttpRequest to a controller just like any other CI request. I always send extra parameters with my ajax calls that I use for security purposes because testing the headers is not sufficient to guarantee security. The controller checks security and forwards the request on the appropriate Model to gather the required data...
3) The Model (as in your example) gathers the required data (in your example the posts) packages the data into a JSON string and immediately echos that output to the client.
4) The client recieves the JSON string and places the contents into the newly created DOM element.
5) Process complete.
That's the way I do it. I'm considered somewhat of a heretic for this method...but this is efficient and the most direct route to achieving your goal.
More helpful?
Randy