I know the way that I'm currently implementing ajax page loads is not the best way to do it. It goes like this:
I have a module (that I created) that has a path to send all ajax request though. based on the urls parameters, it's able to figure what actual page (node) needs to be loaded. It just returns a json_encoded string for processing (rendering is done client side).
The trouble with Drupal is that it wants to decorate EVERYTHING with all the templates. So I get json intermingled with html. I obviously don't want that. I don't want any rendering done at all in fact. So far, the only thing I've come up with on my own is to implement hook_page_alter and just unset as much data as possible until it renders with only the json. That was working for a while.
This has brought up the issue of my method of processing the ajax.
What is considered best practice for this type of thing? Ultimately, there may be minimal server side rendering, but I want the data to be sent in chunks that I can inject in various parts of the page. I don't want to have to put in all in one spot. To the ajax_response.title would go in the div with id="title" and the ajax_response.body would go in the div with id="body". There may be info between those two that I don't want to replace/re-render between requests.
Mostly my question is this: How can I tell drupal to send exactly the text that I want as a response instead of insisting on decorating the response with templates and allowing modules to add information?