开发者

open browser instance from $ajax

开发者 https://www.devze.com 2023-03-05 05:36 出处:网络
i am trying to open a new browser instance popup to show the contents of a file so not staying in the same page?

i am trying to open a new browser instance popup to show the contents of a file so not staying in the same page?

    $(document).ready(function (event) {

        $.ajax({
      开发者_如何学Python      type: 'POST',
            url: "/Home/Index"
        });

    })

 public ActionResult Index()
    {
        return File(@"C:\TextFile1.txt", "text/plain");
    }


What about without ajax?

$(document).ready(function (event) {
    window.open('/Home/Index', 'Window name')
})

If you require ajax, because you need to POST data

$(document).ready(function (event) {
    $.ajax({
        type: 'POST',
        url: "/Home/Index",
        success: function( data ) {
           var win = window.open('about:blank', 'Window name');
           $(win.document.body).append(data);
        }
    });
})
0

精彩评论

暂无评论...
验证码 换一张
取 消