$(document).ajaxSend(function (e, xhr, o) { // 截獲RunReport請求 if (o.url.indexOf('/ActiveReports.ReportService.asmx/RunReport') > 0) { xhr.abort(); // 終止AR默認請求 $.ajax({ type: "POST", url: o.url, global: false, // 這句很重要再也不觸發ajaxSend事件,否則會走死循環 data: o.data, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var msgStr = JSON.stringify(msg); msgStr = msgStr.replace(/給不能爲 null 的參數指定一個 null 值/g, '此字段爲必填項'); msg = JSON.parse(msgStr); o.success(msg); }, error: o.error }); } });