Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display json in a new browser tab page

I have been trying for 4 days to solve this problem. But I cannot return json data into a new tab page.

My code:

<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>

Controller:

    public ActionResult PanelGoster(MyModel model)
    {
    var stringView = RenderRazorViewToString("PartialView", MyModel());
    return Json(stringView, JsonRequestBehavior.AllowGet);
    }
    }
like image 433
user2902180 Avatar asked Oct 26 '13 13:10

user2902180


1 Answers

try

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

from Open a new tab/window and write something to it?

like image 69
Abu Romaïssae Avatar answered Oct 13 '22 00:10

Abu Romaïssae