6

我已经尝试了 4 天来解决这个问题。但我无法将 json 数据返回到新的标签页。

我的代码:

<script type="text/javascript">
function CustomerId() {

var url = "Home/PanelGoster";  // My URL

var veri = {
Id: Id.GetValue(),
};

$.ajax({
url: "/Home/PanelGoster",
type: "POST",
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(veri),
success: function (mydata) {
if (mydata.error6 == true) {

}
else { // Success

var something = window.open(url, '_blank');  // Problem Here , it does not work
something.focus();   // Problem Here


("#MusterilerGetir").html(mydata);          // Problem Here, should be displayed in a new tab
}
},
error: function () {

}
});
return false;
}
</script>

控制器:

    public ActionResult PanelGoster(MyModel model)
    {
    var stringView = RenderRazorViewToString("PartialView", MyModel());
    return Json(stringView, JsonRequestBehavior.AllowGet);
    }
    }
4

1 回答 1

11

尝试

something = window.open("data:text/json," + encodeURIComponent(mysdata),
                       "_blank");
something.focus();

打开一个新的标签/窗口并写一些东西给它?

于 2013-10-26T13:33:42.233 回答