如何使用jQuery/AJAX将表单数据发布到新窗口? [英] How to post form data to a new window using jQuery/AJAX?

查看:120
本文介绍了如何使用jQuery/AJAX将表单数据发布到新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中的一个页面具有一组链接,这些链接在单击时会基于TableTools jQuery插件发布表单数据.我想在一个新窗口中打开这个新页面.关于最佳方法的任何想法吗?我宁愿不将所有操作链接都更改为单个表单,而使用target ="_ blank".我尝试调用一个新窗口以成功打开,然后将数据写入此页面,但这一直没有用.请帮忙!

One of the pages in my application has a set of links that when clicked, posts form data based on the TableTools jQuery plugin. I'd like this new page to open up in a new window. Any ideas on the best way to do this? I'd rather not change all of my action links over to individual forms and use target="_blank". I've tried calling a new window to open on success, and posting writing the data to this page, but that hasn't been working. Please help!

HTML:

<div id="action">                        
    Download
</div>   

JavaScript:

Javascript:

$('#action').click( function () { 

    var userData = oTable.fnGetColumnData(0);

    $.ajax({
        type: "POST", 
        url: "../download.php",
        data: "user_list=" + userData,
        dataType: "json",
        success: function(data){
            var win = window.open();
            win.document.write(data);
        }
    })  

})

推荐答案

找到了答案:

未执行jQuery.ajax成功回调函数

当我拿出dataType: "json"时,它起作用了!

When I took out the dataType: "json", it worked!

这篇关于如何使用jQuery/AJAX将表单数据发布到新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆