Jquery帖子,在新窗口中响应 [英] Jquery post, response in new window
本文介绍了Jquery帖子,在新窗口中响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个脚本,on.DocumentReady将数据发布到另一个页面。该页面以一个div标签封装了一些HTML。
I have a script that on.DocumentReady posts data to another page. That page responds with some HTML encapsulated in one div tag.
我的目标是在新窗口中打开此帖子响应/数据。
My goal is to have this post response/data open in a new window.
任何提示或线索?
以下是我根据Mille博士的建议创建的片段。
Here is the snippet I created from Dr. Mille's advice.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var packslip_id = 35592;
var po_no = 0018439;
var box_no = 1;
$.post("https://example.com/barcode/generate", { packing_slip: packslip_id, reference: po_no, total_boxes: box_no},
function (data) {
alert(data);
var win=window.open('about:blank');
with(win.document)
{
open();
write(data);
close();
}
});
});
推荐答案
使用写() - 弹出文档的方法将标记放在那里:
Use the write()-Method of the Popup's document to put your markup there:
$.post(url, function (data) {
var w = window.open('about:blank');
w.document.open();
w.document.write(data);
w.document.close();
});
这篇关于Jquery帖子,在新窗口中响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文