* 在 ajax 中用浏览器打开接受到的信息(整张html文本).
a). 在学习的过程中,碰到这样的问题,ajax 提交服务器后,返回接受到的是一张html文本信息,需要在success里重新打开一个标签页,并且将页面显示, 最开始解决办法:
$.ajax({ //传值
url: 'url',
type: 'post',
success : function(data) {
var x=window.open();
var htmlvalue=$(data);
$(x.document.body).html(htmlvalue);
},
error:function(data){
alert("'error'");
}
});
但是:接受到的文本信息中,含有
$.ajax({ //传值
url: 'url',
type: 'post',
success : function(data) {
var x=window.open();
x.document.open();
x.document.write(data);
x.document.close();
},
error:function(data){
alert("'error'");
}
});
这样就能够将html文本信息中,
里的 script 应用于新打开的标签页。内容链接来自:http://stackoverflow.com/questions/9399354/how-to-open-a-new-window-and-insert-html-into-it-using-jquery。