3 ms·
The sensible way to combine classical REST and AJAX (which I think original AJAX did open for, with it being Asynchronous JavaScript and XML) is to allow reques
by e12e 13y ago
The sensible way to combine classical REST and AJAX (which I think
original AJAX did open for, with it being Asynchronous JavaScript and
XML) is to allow requesting partial documents. So if you have:
<xml><d><p>I am initial document, I have only one thing to say, and that
is hello!</p></d></xml>
At, /document.xml
You should be able to get a partial: <p>I am p2</p> from something like
/document.xml?2 /doucument.xml/2 or something.
Then all that could be cached, and you only send new sections.
But yes, the client does need to keep some state, because HTML doesn't
support transclusion[1] of the "most important" html elements:
paragraphs, divs etc. So you can transclude an image, or (badly imnho)
an entire document through an iframe -- or javascript (henche modern
ajax, which is basically asynchronous javascript and javascript or json
which is basically javascript).
There's no real contrast between REST and AJAX as an architecture, as
such. What's maybe missing is server-to-client PATCH or something (eg:
client says I've got d1.html as of <some-date>, give me a diff).
Wouldn't that have solved almost all our problems?
[edit: I hereby reserve the http method "DIFF" as a reverse "PATCH", as for some strange reason no-one seems to have defined this before (as far as I can google, anyway). Semantics to be hammered out, but in general a client does a "DIFF /<uri>" along with a cache header/timestamp/sha512-hash, and gets back either an unchanged header, or a reply with a patch to be merged with the document/uri in question in order to get an up-to-date copy.
In other words, a DIFF is to GET as PATCH is to PUT ]
[1] https://en.wikipedia.org/wiki/Transclusion https://en.wikipedia.org/wiki/Transclusion
[2] https://tools.ietf.org/html/rfc5789 https://tools.ietf.org/html/rfc5789