ajax返回xml根节点

function _getAjaxDocumentRoot(xmlHttpRequest){
 var root = null;
 if (xmlHttpRequest.responseText.length == 4)
  return null;
 if (xmlHttpRequest.responseXML.xml == "" && xmlHttpRequest.responseText != ""){
  try {
   var doc = new ActiveXObject ("Microsoft.XMLDOM");
   var xmlText = Start.Util.decodeText(xmlHttpRequest.responseText);
   doc.loadXML (xmlText);
   root = doc.documentElement;   
  } catch (e) {
   root = null;
  }
 }else{
  try {
   root = xmlHttpRequest.responseXML.documentElement;
  } catch (e) {
   root = null;
  }
 } 
 return root;
}

你可能感兴趣的:(Ajax)