Ajax sites often make use of the XMLHttpRequest component to access the backend server. This works really well when you're using it to contact your own server, i.e. the server the page was originally served from.
However, what if you want to include, ajax style, a snippet of content on a client's site, without them having to proxy your content to the client via their own server? With XMLHttpRequest, you can't. Sorry.
Well, I found a curious hack. The tag can be used to download javascript, and can download it from anywhere, i.e. no security restrictions on it. So, why not encode your content as Javascript? Hmm.
So, say your snippet of HTML is:
<div><h1>Heading</h1><p>This is the important message.</p></div>
Well, you encode this as:
document.write("<div><h1>Heading</h1><p>This is the important message.</p></div>");
And, with web frameworks such as Cocoon, it wouldn't be too hard to write a JSEncodingSerializer that takes in text and encodes it as Javascript. All it would need to do would be to put 'document.write("' at the beginning, '");' at the end, and replace all occurances of double quotes with \", and strip out all carriage returns (don't forget \r for your Windows clients).
And, believe me, it works. Hmm.