This is a great topic. With all the freedom MODX provides there are many ways to accomplish something like this. I've been told that using a central Ajax processor (like a resource with an uncached snippet) is perfectly sensible. I've always wondered though, if making conditional templates that process either then entire page or just what is needed for an Ajax request could make more sense. What if you need to fetch the value of several TVs? Would doing this from the resource itself be faster?
Say you have blog posts and you want to be able to request just their comments over Ajax. The first step is to reduce your blog post template to one Chunk, so it can be included conditionally.
Now we need a way to look for a 'ajax' URL parameter to determine if we should load the whole page or just Ajax request. I will use the getUrlParam Extra.
I'll use the If snippet for the conditional since I think it is more legible than output modifers.
[[[[!If? &subject=`[[!getUrlParam? &name=`ajax` &int=`1`]]` &operator =`eq` &operand=`1` &then=`$blog-post-ajax` &else=`$blog-post`]]]]
Since this is being done from the resource itself, all of the Template Variables will be available using the
syntax. Whether or not this technique has worthwhile performance benefits I'm not certain. Also I always get confused on whether or not both the If and getUrlParam need to be uncached, but I believe they both do.