ajax成功时隐藏url和参数

hide url and parameters when ajax success

本文关键字:参数 url 隐藏 成功 ajax      更新时间:2023-09-26

我有以下ajax js代码。/menu/solonreport.jsp返回一个类似这样的url链接,连接到本地报表服务器并创建一个excel报表。

window.open(json.url)在新窗口中打开链接,但我不想向用户显示链接和更多参数。

这可能吗?

function getEventTarget(e) {
   e = e || window.event;
   return e.target || e.srcElement;
}
var ul = document.getElementById('menureport');
ul.onclick = function(event) {
   var target = getEventTarget(event);
   var reportid = target.id;
   var reporttype = target.innerHTML;
   alert(reportid);
   $.ajax({
       type: 'GET',
       url: '../menu/solonreport.jsp',
       data: {
           Wreportid: reportid,
           Wreporttype: reporttype
       },
       async: false,
       dataType: 'json',
       success: function(json) {
           window.open(json.url);
       }
   });
}

执行

window.open(json.url,'PDF','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no');

但这取决于浏览器如何处理。