I know it\'s already discussed here, but there were no solution to get the whole document (including doctype).
$(document).html(); returns null
$(document).html();
null
try this.
$("html").html()
document is a variable it dose not represent the html tag.
EDIT
To get the doctype one could use
document.doctype