JQuery打开新屏幕

时间:2013-04-03 11:20:22

标签: jquery

我正在尝试使用JQuery打开一个新屏幕,但必须将变量传递到新屏幕。这可能吗?我在带有MVC 4的Visual Studio 2012中有一个C#应用程序。 我的代码如下所示:

    $('#AddCopyRuleButton').click(function () {
        var url = '@Url.Action("GetDetails")';
        var data = {
            systemCode: $('#SystemCode').val(),
            productCode: $('#Products').val(),
            subProductCode: $('#SubProducts').val(),
            division: $('#Division').val(),
            dcarFrom: $('#DCARFrom').val(),
            dcarTo: $('#DCARTo').val(),
            accountNumber: $('#AccountNumber').val(),
            counterPartyCode: $('#CounterParty').val()
        };

        $.getJSON(url, data, function (data) {
        });
    });

在JSON代码中,我想重定向到另一个页面,并将数据和请求一起发送到新页面。应该关闭当前页面。

另外,如何使用传递给新屏幕的数据?

2 个答案:

答案 0 :(得分:0)

您不需要异步请求,请使用原始的urlencoded GET请求。

答案 1 :(得分:0)

你可以按照

的方式做点什么
// Parent window
$('#AddCopyRuleButton').click(function () {
    var p=window.open("Popup.html");

    // wait for the child to get populated and then close this window
    window.close();
});

function getData() {
    var iHoldData;
    // Put some stuff in iHoldData
    return iHoldData;
}

对于孩子

// Child window
$(document).ready(function() {
    if(window.opener && !window.opener.closed) {
        var iRecieveData = window.opener.getData();
    }
});