BlogMatrix
 

Introducing JAHAH

edit David Janes 2006-01-05 13:18 UTC 1  comment  ·

This page is permanently available here.

What is JAHAH?

JAHAH is an AJAX-like technology for 'mashing' web pages together.

  • It is easy for web page authors to include JAHAH documents
  • It is easy for content producers to create JAHAH documents
  • JAHAH documents can be included "cross-domain", unlike most AJAX technologies
  • JAHAH documents are search engine friendly

Where does JAHAH come from?

JAHAH is based on existing ideas and technology:

  • AHAH is technology for directly including HTML fragments using AJAX
  • JSON is a scripting-language friendly way of transmitting data across the web (that works cross-domain)
  • JSONP is an incremental improvement to JSON that allows the document requestor to specify an arbitrary prefix to be returned prepended to the result

JAHAH Web Service Description

A web service that provides JAHAH documents must behave as following:

  • If there is a 'jsonp' parameter, it must return:
    • the value of that parameter, followed by
    • if everything's OK, a dictionary with 'html' containing the payload
    • if there's a problem, a dictionary with 'error' containing the error message
  • If there is no 'jsonp' parameter, or it is empty, the webservice must return an HTML document, where the BODY of the document is the payload

It is also acceptable, though not encouraged, to return only a string with the payload rather than a dictionary. It is OK to return other values with the dictionary, excepting that all single letter keys are reserved.

How do I include JAHAH in my document?

You are free to do this anyway you like if you don't care for what we've done here. However, we do provide some pretty nifty tools if you want to try them. Note that do not add the 'jsonp' parameter to URIs here -- our code provides this function automatically to callback to the correct places.

NOTE: our JAHAH tools use MochiKit. We include a copy in our little source distribution for now, but we may take it out if this thing starts rolling.

Automatically load by magically marked likes

<script type="text/javascript" src="jahah.js"></script>
...

<a rel="jahah-include" href="http://www.example.com/jhah-service/">loading...</a>

Load a JAHAH document into a element (by ID)

<script type="text/javascript">
loadJSONDoc("http://www.example.com/jhah-service/", "element-id")
</script>

Show me something

Demos 3, 4 and 5 are the best

  • Demo 1 — call document.write to synchronously load a document
  • Demo 2 — call loadJSONDoc asychronously load a JAHAH document
  • Demo 3 — include three different documents using rel="jahah-incldue"
  • Demo 4 — include a RSS feed in a document
  • Demo 5 — chose a URI an watch it get included

What JAHAH web services are available?

Our web services include a little form interface so you can play around with them. Remember that if you don't place something in the 'jsonp' parameter, a HTML document will be returned.

  • jahah-include — extract the body or a fragment of another document and return it as a JAHAH document
  • jahah-feed — convert an RSS/Atom feed into a JAHAH document. This needs some presentation options added, such as to return the doc XOXO microformatted.

Where can I get the source?

http://www.blogmatrix.com/tools/src/

Problems?

  • Errors in loading the JAHAH document are not handled at all. This is very very bad. It's a matter of trapping 'document.onerror' and doing something with it
  • Post-loading of content is imcompatable with Greasemonkey, which means tools such as microformat-action do not work.
  • Mashing documents means that microformatted content cannot be directly recognized. HOWEVER, since all JAHAH documents are available as HTML documents (just omit the 'jsonp' parameter), we could add rel="jahah-include hatom xfolk" to indicate that there's 'hatom' and 'xfolk' content at the other side of the link.
  • We're not in the business of providing a webservice so others can take other's content. At some point 'jahah-include' will block strange referrers
  • 'jahah-include' does not rewrite URIs and thus links and images are often broken. We're going to fix this
Tagged: ajax, ahah, json, jsonp, web2.0, jahah, microformats.

Comment #1Kristen

2008-10-05 10:34:47

Useful article, thanks.

 I was guided to this article by a link to http://www.blogmatrix.com/tools/jahah/ (as referenced in your page by " This page is permanently available here.") but that link 404's; although I was able to find this page via Google etc., others may not bother, so you may wish to fix the reference.