xmlHttprequest on data:// URLs does not work in webkit nightly build var req = new XMLHttpRequest(); //var url = "http://www.google.com"; var url = 'data:text/html;charset=utf-8,%3C!DOCTYPE%20HTML%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20HTML%204.0%2F%2FEN%22%3E%0D%0A%3Chtml%20lang%3D%22en%22%3E%0D%0A%3Chead%3E%3Ctitle%3EEmbedded%20Window%3C%2Ftitle%3E%3C%2Fhead%3E%0D%0A%3Cbody%3E%3Ch1%3E42%3C%2Fh1%3E%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E%0D%0A'; req.open('GET', url, true); req.onreadystatechange = function(aEvt) { if( req.readyState == 4 && req.status == 200) { var div_id = document.getElementById('xxx'); div_id.innerHTML = req.responseText; } } req.send(null);
Created attachment 14826 [details] HTML that does a XHR on data://URL Add this file to a http:// server and launch in safari.
This does not work in Firefox either, and handling of data:// URLs is not specified in draft XMLHttpRequest spec. Does this work in Internet Explorer? I'm particularly suspicious about the "req.status == 200" check - status is HTTP-specific, and does not apply to other protocols. Also, what are the use cases for this? I mean, instead of loading a data:// URL, one can just use a string literal.
It seems that Opera is the only browser that supports XHR on data:// URLs, and this feature is unlikely to get into the spec. See the thread <http://lists.w3.org/Archives/Public/public-webapi/2007Oct/0001.html>. Since no use cases were presented, I don't see any value in implementing this.
Could you reconsider this? Now, Firefox and Opera supports XHR for data: URL and some APIs have interface to get content as data: URL. https://bugzilla.mozilla.org/show_bug.cgi?id=702820
*** This bug has been marked as a duplicate of bug 109199 ***