Jquery获取Content-type

姜磊
2023-12-01

//判读返回的Content-Type,处理json或者文件下载
$.post(export_url,function(data,textStatus, jqXHR){
            	var content_type = jqXHR.getResponseHeader("Content-Type");
            	if(content_type=="text/html"){
            		var data =  JSON.parse(data);
            		if(data.status===false){
               		 confirm_("暂无数据!");
               	   }
            	} else{//excel文档
            		 window.location.href = export_url;//下载excel
            	 }
            });


 类似资料: