JQuery打开新屏幕
我试图用JQuery打开一个新屏幕,但必须将变量传递到新屏幕。这可能吗?我在VisualStudio2012中使用MVC4开发了一个C#应用程序。 我的代码如下所示:JQuery打开新屏幕,jquery,Jquery,我试图用JQuery打开一个新屏幕,但必须将变量传递到新屏幕。这可能吗?我在VisualStudio2012中使用MVC4开发了一个C#应用程序。 我的代码如下所示: $('#AddCopyRuleButton').click(function () { var url = '@Url.Action("GetDetails")'; var data = { systemCode: $('#SystemCode').val(),
$('#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代码中,我想重定向到另一个页面,并将数据与请求一起发送到新页面。应关闭当前页面
另外,如何使用传递到新屏幕的数据?您不需要异步请求,请使用原始URL编码的
GET
请求。您可以按照
// 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();
}
});
你是说在另一个页面上发布帖子吗?还是使用JSON作为查询参数的GET?无论哪种方式,MVC自动映射都可能是您的朋友,您应该能够在控制器操作上指定一个适当命名的参数来处理您的请求并为您进行映射。此外,您是否有理由希望打开一个新页面/屏幕,而不是以常规方式导航?