XMLHttpRequest 2

Since the first version of XMLHttpRequest is now more or less stable (last XMLHttpRequest draft published three days ago) I have been thinking a little bit about what type of enhancements we can make for XMLHttpRequest version 2. Here is one thing I have been thinking about:

// start "script block" var r = new XMLHttpRequest(uri); // uri argument causes implicit invocation of r.open("GET", uri) r.setRequestHeader("Accept", "text/html") r.onload = function() { … } r.onerror = function() { … } r.onabort = function() { … } // end "script block" causes implicit invocation of r.send()

This is similar to how new Audio(uri) works in HTML5 and I think it is rather elegant. I think some browser extensions such as overrideMimeType to set the MIME type and responseBody to get a byte array of the response will also be added and maybe a way to better determine what exactly made the request fail. We will also be looking into integrating it with the Progress Events draft so you can track uploading and downloading of data more accurately. Finally, in combination with the Enabling Read Access for Web Resources draft we can allow cross domain requests as I mentioned earlier.

Copyright © 2003-2020 Anne van Kesteren