Sunday, 15 January 2012

javascript - jquery Cannot read property 'getAttribute' of undefined -


Javascript I'm using fully working fine in Firefox, but this error is run on Chrome and Safari I am not sure why this is unsuccessful.

  var response = asyncResult.value; If (window. DOMParser) {var parser = new dumpparser (); XmlDoc = parser.parseFromString (feedback, "text / xml"); } And {xmlDoc = new ActiveXObject ("Microsoft.XMLDOM"); XmlDoc.async = false; XmlDoc.loadXML (feedback); } Console.log (xmlDoc); Var changeKey = xmlDoc.getElementsById ("t: ItemId") [0] .getAttribute ("ChangeKey");  

The console shows this message, but when I set it to console.log () it simply outputs to xmldoc


  Unkit type error: Can not read attribute properties undefined r.js soapToGetItemDataCallback r.js r.onreadystatechange outlookwebapp-15.js's 'getAttribute':. 21 $ h.EwsRequest $ 1x_1 outlookwebapp-15.js: 21 (anonymous function) outlookwebapp-15.js: 21  

The problem is that you are an element based on ID and trying to use [0] , I think you want getElementsByTagName Because that is the result should be undefined,:

  changeKey = xmlDoc.getElementsById ("T: Itemid") .getAttribute ("ChangeKey");  

Or if "T: Itemid" is a collection:

  on changeKey = xmlDoc.getElementsByTagName ("T: Itemid ") [0] .getAttribute (" ChangeKey ");  

No comments:

Post a Comment