3

so I'm getting an email's HTML response back from the server and in jQuery I'm trying to render that response into a popup window.

I tried this at first:

postToServerWithAjax('/invite_preview', null, function (response) {
    window.open($(response), "popupWindow", "width=600,height=600,scrollbars=yes");
});



However that just opened up the Popup window with [object, object] in the URL. I tried .html() below

postToServerWithAjax('/invite_preview', null, function (response) {
    window.open($(response).html(), "popupWindow", "width=600,height=600,scrollbars=yes");
});

^ And this just returned a blank popup window


I then tried just a blank page, but my code keeps placing the HTML into the url bar:

window.open(response).html();

enter image description here

What am I missing to actually render the HTML into the new popup/page?


Found some examples here, and used the answers, but haven't gotten the HTML to render yet :(

display html code of response returned by ajax, Jquery

jQuery function to open link in new window

Community
  • 1
  • 1
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529

1 Answers1

8

The first parameter is a URL, not actual content, you have to write that to the window

postToServerWithAjax('/invite_preview', null, function (response) {
   var wind = window.open("", "popupWindow", "width=600,height=600,scrollbars=yes");
   wind.document.write(response);
});
adeneo
  • 312,895
  • 29
  • 395
  • 388