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);
}
});
})
精彩评论