服務端返回json類型數據,解析問題html
git 報告提交java
服務端MIME使用text/html 類型 返回普通json字符串;git
jquery.dtgrid.js : line :240 在ajax的success回調函數中第一句加入驗證ajax
$.ajax({ type:'post', url:url, data:params, contentType: "application/x-www-form-urlencoded; charset=utf-8", beforeSend: function(xhr) {xhr.setRequestHeader("__REQUEST_TYPE", "AJAX_REQUEST");}, success:function(pager){ if(typeof pager === "string"){ pager = $.parseJSON(pager); } //若是出錯表示有多是程序問題或高級查詢方案配置有誤 if(!pager.isSuccess){ $.fn.DtGrid.tools.toast($.fn.DtGrid.lang[dtGridReflectionObj.option.lang].errors.ajaxLoadError, 'error', 5000); dtGridReflectionObj.hideProcessBar(); return; }
服務端view構建,json
public class DTGridView { /** * 用途:高級查詢的查詢參數合集,將由組件根據用戶選擇自行生成。<br/> */ private List<String> advanceQueryConditions; /** * 用途:高級查詢的排序參數合集,將由組件根據用戶選擇自行生成。<br/> */ private List<String> advanceQuerySorts; /** * 用途:是否導出所有數據,將由組件根據用戶選擇自行處理。<br/> */ private boolean exportAllData = false; /** * 用途:導出的列集合,將由組件根據用戶選擇自行處理。<br/> */ private List<String> exportColumns; /** * 用途:導出的數據是否已經被處理。<br/> * 該屬性爲先後臺的一個數據處理標識,經由resolution、數據格式化等操做完成處理的數據被視爲已處理。<br/> */ private boolean exportDataIsProcessed; /** * 用途:高級查詢的查詢參數合集,將由組件根據用戶選擇自行生成。<br/> */ private String exportFileName; /** * 用途:導出的文件類型,將由組件根據用戶選擇自行處理。<br/> */ private String exportType; /** * 用途:展現的數據結果集。<br/> */ private List<Map<String, Object>> exhibitDatas; /** * 用途:導出的數據集合,將由組件根據用戶選擇自行生成,生成的導出數據均爲處理後的數據。<br/> */ private List<Map<String, Object>> exportDatas; /** * 用途:快速查詢的參數合集,將由組件根據用戶選擇自行生成。<br/> */ private Map<String, Object> fastQueryParameters; /** * 用途:用於判斷前臺的交互信息是否爲導出的動做。<br/> */ private boolean isExport; /** * 用途:數據是否加載成功,若查詢SQL出現錯誤或高級查詢中配置錯誤,則該返回值爲false,正確查詢則爲true。<br/> */ private boolean isSuccess; /** * 用途:當前頁號。<br/> * 特殊說明:該參數能夠手動修改。 */ private int nowPage; /** * 用途:當前查詢的紀錄總頁數。 <br/> */ private int pageCount; /** * 用途:每頁的顯示的記錄條數。<br/> */ private int pageSize; /** * 用途:自定義參數集合。該參數可經過Javascript手動設置,屬性類型爲Object對象。<br/> * 能夠經過Javascript設置參數,設置完成後經過服務器端封裝的Pager對象訪問對象中的parameters屬性便可得到對應參數集合,<br/> * 該集合對應Java服務器爲Map對象。 */ private Map<String, Object> parameters; /** * 用途:當前查詢的紀錄總數。<br/> */ private int recordCount; /** * 用途:開始的記錄號。<br/> */ private int startRecord; /** * 默認初始化數據 */ public DTGridView() { this.advanceQueryConditions = Lists.newArrayList(); this.advanceQuerySorts = Lists.newArrayList(); this.exportAllData = false; this.exportColumns = Lists.newArrayList(); this.exportDataIsProcessed = false; this.exportFileName = "exportfilename"; this.exportType = ""; this.exhibitDatas = Lists.newArrayList(); this.exportDatas = Lists.newArrayList(); this.fastQueryParameters = Maps.newHashMap(); this.isExport = false; this.isSuccess = false; this.nowPage = 1; this.pageCount = 0; this.pageSize = 0; this.parameters = Maps.newHashMap(); this.recordCount = 0; this.startRecord = 0; } public List<String> getAdvanceQueryConditions() { return advanceQueryConditions; } public void setAdvanceQueryConditions(List<String> advanceQueryConditions) { this.advanceQueryConditions = advanceQueryConditions; } public List<String> getAdvanceQuerySorts() { return advanceQuerySorts; } public void setAdvanceQuerySorts(List<String> advanceQuerySorts) { this.advanceQuerySorts = advanceQuerySorts; } public boolean getExportAllData() { return exportAllData; } public void setExportAllData(boolean exportAllData) { this.exportAllData = exportAllData; } public List<String> getExportColumns() { return exportColumns; } public void setExportColumns(List<String> exportColumns) { this.exportColumns = exportColumns; } public boolean getExportDataIsProcessed() { return exportDataIsProcessed; } public void setExportDataIsProcessed(boolean exportDataIsProcessed) { this.exportDataIsProcessed = exportDataIsProcessed; } public String getExportFileName() { return exportFileName; } public void setExportFileName(String exportFileName) { this.exportFileName = exportFileName; } public String getExportType() { return exportType; } public void setExportType(String exportType) { this.exportType = exportType; } public List<Map<String, Object>> getExhibitDatas() { return exhibitDatas; } public void setExhibitDatas(List<Map<String, Object>> exhibitDatas) { this.exhibitDatas = exhibitDatas; } public List<Map<String, Object>> getExportDatas() { return exportDatas; } public void setExportDatas(List<Map<String, Object>> exportDatas) { this.exportDatas = exportDatas; } public Map<String, Object> getFastQueryParameters() { return fastQueryParameters; } public void setFastQueryParameters(Map<String, Object> fastQueryParameters) { this.fastQueryParameters = fastQueryParameters; } /** * @WARN 注意使用idea 根據屬性生成getter setter時, * boolean值類型的方法名稱,ide生成getExport,實際變量名isExport,應生成getIsExport * @return */ public boolean getIsExport() { return isExport; } public void setIsExport(boolean isExport) { this.isExport = isExport; } /** * @WARN 注意使用idea 根據屬性生成getter setter時, * boolean值類型的方法名稱,ide生成getSuccess,實際變量名IsSuccess,應生成getIsSuccess * @return */ public boolean getIsSuccess() { return isSuccess; } public void setIsSuccess(boolean isSuccess) { this.isSuccess = isSuccess; } public int getNowPage() { return nowPage; } public void setNowPage(int nowPage) { this.nowPage = nowPage; } public int getPageCount() { return pageCount; } public void setPageCount(int pageCount) { this.pageCount = pageCount; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public Map<String, Object> getParameters() { return parameters; } public void setParameters(Map<String, Object> parameters) { this.parameters = parameters; } public int getRecordCount() { return recordCount; } public void setRecordCount(int recordCount) { this.recordCount = recordCount; } public int getStartRecord() { return startRecord; } public void setStartRecord(int startRecord) { this.startRecord = startRecord; }