During the parsing process, IE8 and above, Google and Firefox all need to parse xml,
Parse attribute: ajaxResponse[0].getAttribute("createFlag")
Parse node text: ajaxResponse[0].childNodes[0].nodeValue
Remember text is also a node
The above operations support any browser
<%@ page contentType="text/xml;charset=utf-8"%><?xml version="1.0" encoding="utf-8"?> <ajax-response> <response type="object" id="" userServiceCode="${userServiceCode}" calculationPriceCode="${calculationPriceCode}" StrutsErrorIndex="${StrutsErrorIndex}" userName="${userName}" userCode="${userCode}" message="${message}" exception="${exception}" ResType="${ResType}" resStatus="${resStatus}" bussType ="${bussType}" invented ="${invented}" orgCode ="${orgCode}" msgSelectFlag ="${msgSelectFlag}" waitSeeSize = "${waitSeeSize}" opType ="${opType}" orgType="${orgType}" paramCode="${paramCode}" custCode="${custCode}" custEq="${custEq}" ifStatic="${ifStatic}" identification="${identification}" writeStr="${writeStr}" createFlag="${createFlag}" > ${tempMap} </response> </ajax-response>
var ajaxResponse = response.responseXML.getElementsByTagName("response"); if(ajaxResponse[0].getAttribute("createFlag") == 1){//Save the page if(navigator.userAgent.indexOf("MSIE")>0){ if(navigator.userAgent.indexOf("MSIE 8.0")>0){//Judging IE8 browser alert("IE8"); }else{//Other IE series browsers alert("Other IE"); } }else{//Other browsers alert("Other browsers"); } alert("value------------>"+ajaxResponse[0].childNodes[0].nodeValue);//Get the value of the text node }
The ultimate judgment of whether it is an IE browser: the above method cannot be judged for IE11, and the following code can judge IE11
/ / Determine whether it is an IE browser function isIE () {// ie? if (!!window.ActiveXObject || "ActiveXObject" in window) return true; else return false; }