The following code works in Safari and Chrome, which is to say, it displays a copy of itself in the browser window:
<script src=https://code.jquery.com/jquery-2.1.3.min.js></script>
<script>
function html_escape(s) { return $('<div/>').text(s).html(); }
var url = document.location.href;
$.get(url, function(data,status) {
document.write('<pre>');
document.write(html_escape(data));
document.write('</pre>');
});
</script>
But in Firefox it fails with the error "Not well formed", which I presume is because FF is trying to parse the contents of the file as XML. How can I stop FF from attempting to parse the file?
UPDATE: The problem only manifests itself when I run from a FILE: URL, so there is no MIME type. But that is in fact my use case.