Q:

Get entire html page as response with javascript

I am doing an Ajax post to a specific page where I either can get an ID as response if everything went as expected or I could get a random html page and a http 400 as response if something went wrong. In the error case I want to open up the entire html page in a new window. I have tried the following but it is not working - it sets the variable data to [object Object] instead of the intended html page. 
$.ajax({
    type: "POST",
    url: postUrl,
    data:'message=' + message + '&' + 'title=' + title,
    statusCode: {
            400:function(data) {
                var newWin = open('','windowName','height=300,width=300');
                newWin.document.write(data);
        },
    },
    success: function(json) {
        alert("Post success");
    },
    error: function(jqXHR, textStatus, errorThrown) {
        alert("Error connecting to page.");
    }
});

A:

Specify dataType : 'html' and change the success function variable. Example:
$.ajax({
    type: "POST",
    dataType: 'html',
    url: postUrl,
    data:'message=' + message + '&' + 'title=' + title,
    statusCode: {
            400:function(data) {
                var newWin = open('','windowName','height=300,width=300');
                newWin.document.write(data);
        },
    },
    success: function(html) {
        alert("Post success");
        $("#myDiv").html(html);
    },
    error: function(jqXHR, textStatus, errorThrown) {
        alert("Error connecting to page.");
    }
});

