如何将文件路径从控制器中的操作传递到 $.AJAX 成功函数。
[HttpPost]
public JsonResult OrgLevelReport(string startdate, string enddate)
{
string file = "D:/Sample.xlsx";
return Json(file);
}
$.ajax({
url: '@Url.Action("OrgLevelReport", "Reports")',
type: 'POST',
data: { startdate: startdate, enddate: enddate },
datatype: 'json',
success: function (bbb) {
alert(bbb);
alert("1");
if (window.ActiveXObject) {
try {
var objExcel;
objExcel = new ActiveXObject("Excel.Application");
objExcel.Visible = true;
objExcel.Workbooks.Open(bbb, false);
}
catch (e) {
alert(e.message);
}
} else {
alert("Your browser does not support this.");
}
}
});
alert(bbb)
行显示 PK...无效字符串而不是实际字符串。