tags:

views:

55

answers:

2

Is it possible to post data to a new window without using hidden input fields. Data can be possibly quite large. Looking at something similar to jQuery ajax type post.. except I need to post the data to a new page.

A: 

A hidden form is the standard approach to this. I don't recall if the following has complications, but you may even be able to create the form on the fly and submit it. In my opinion, there's nothing wrong with this approach. Another possibility is to use jQuery.post() and in the callback function open a new window and paste the returned content. For example,

var win = window.open();
win.document.write(returnedContent);
TNi
upon success, it just returns to the same window doing the post. what i need is for the data to be posted to 'PAGE x' and stay on 'PAGE x' where 'PAGE x' is a popup (new window).
Brandon
How did you open Page X in the first place? If it was with JavaScript on the same page as the one from which you are doing the post, you may still be able to use the second method mentioned. Otherwise, I'm not aware of any way other than with a hidden form (there's a reason it's standard).
TNi
That would be part of my question. If you are not aware of anyway (as I am)... will wait for someone who has the answer.
Brandon
That's fine, and I would welcome any news on this. Because I don't know everything, I always keep open the possibility that I've missed something. However, only bear in mind that it is very likely that there just isn't a way to accomplish what you want in the way you want.
TNi
A: 

eureka! this test works:

function postData() {           
        $.post('popup.aspx', { text1: "aaa", text2: "bbb" }, function (result) {
            WinId = window.open('', 'newwin', 'width=400,height=500');
            WinId.document.open();
            WinId.document.write(result);
            WinId.document.close();
        });
    }

on popup.aspx.cs

test1.Text = Request["text1"];
test2.Text = Request["text2"];

on popup.aspx

<asp:Label ID= "test1" runat="server"></asp:Label>
<asp:Label ID= "test2" runat="server"></asp:Label>
Brandon
I just checked up on this. I may be wrong, but this solution appears to be a refined version of exactly what I suggested, or did I misunderstand your original comments?
TNi