如何将服务器响应作为HTML呈现到弹出窗口中?jQuery的

Leo*_*ban 2 html javascript jquery response

所以我从服务器和jQuery收到了一封电子邮件的HTML响应,我试图将该响应呈现在一个弹出窗口中.

我一开始尝试了这个:

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



然而,这只是在URL中打开了[对象,对象]的弹出窗口.我试过下面的.html()

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

^这只是返回一个空白的弹出窗口


然后我尝试了一个空白页面,但我的代码仍然将HTML放入url栏:

window.open(response).html();
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

实际上将HTML呈现到新的弹出/页面中我缺少什么?


在这里找到一些例子,并使用了答案,但还没有得到HTML渲染:(

显示由ajax,Jquery返回的响应的html代码

jQuery函数在新窗口中打开链接

ade*_*neo 8

第一个参数是URL,而不是实际内容,您必须将其写入窗口

postToServerWithAjax('/invite_preview', null, function (response) {
   var wind = window.open("", "popupWindow", "width=600,height=600,scrollbars=yes");
   wind.document.write(response);
});
Run Code Online (Sandbox Code Playgroud)