Written by Christian Stigen Larsen on 2008-04-15
One of the suggestions in the HTML5 working draft is to allow src attributes for tags such as div. This means you can do:
<div src="http://foo.bar/get_text/?id=123"> </div>
and your web browser will contact foo.bar and insert the resulting text into the div-tag.
This is great news for web page authors! Not only can you fetch text from other web sites, but you can also split up your web site into a lot smaller, light-weight web pages — much like AJAX is used today.
People have been using this for some time with the img element. For instance, to display a map, you could reference an image like this:
<img src="http://foo.bar/map.php?id=123&zoom=2.3" alt="Map" />
Here, map.php will generate a bitmap image and serve up the mime-type and data contents.
However, the src attribute only works with HTTP GET requests. What I propose is to be able to POST data to a service.
I'll give an example. The graphviz package lets one create graphs quite easily from a simple snippet of code. For instance, to create two nodes A and B with a directed edge from A to B, you simply write:
digraph foo {
A -> B;
}
Using the dot program, you can render the graph to vector or bitmap images.
What I basically would want is to embed this code in some POST request, right from the HTML document. I haven't decided exactly how this would be presented in HTML, but something like this could work:
<img method="post" action="http://foo.bar/graphviz/dot/">
digraph foo {
A -> B;
}
</img>
What happens here is that your browser sends the code for the "foo" digraph to the URL http://foo.bar/graphviz/dot/, retrieves the mime-type and image data and displays it on the web page.
This would leverage the ability to split up a site into many smaller code snippets, and would facilitate use of light-weight services.
It would benefit not only server-side programming (PHP, etc), but also client-side use of javascript, which could dynamically generate the text to post.
One should be able to do this for div elements as well, for instance:
<div method="post" action="http://foo.bar/jail/python/"> a = [x**2 for x in range(5)] print a </div>
which would produce:
[0, 1, 4, 9, 16]
The thing is, the W3C would have to decide on how this would best be implemented. I think browser authors would have some good ideas on how to do this in the most compatible and sensible manner.