Jquery – How to post form data to a new window using jQuery/AJAX

ajaxjquerypost

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:

$('#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);
        }
    })  

})

Best Solution

Found the answer:

jQuery.ajax success callback function not executed

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