Permalink
Browse files

Attempt to parse XHR result manually if responseXML is missing

  • Loading branch information...
1 parent 6b9f8ab commit 8f46422c55d058f426f0070e36cd9194a73d81cf @peroo peroo committed Jun 20, 2012
Showing with 16 additions and 2 deletions.
  1. +16 −2 index.html
View
@@ -57,8 +57,22 @@
}
// process the data received from the XHR
- function _processData(xmlDoc)
+ function _processData(xhr)
{
+ var xmlDoc;
+ if(!xhr.responseXML) {
+ var parser = new window.DOMParser()
+ try {
+ xmlDoc = parser.parseFromString(xhr.responseText, "text/xml");
+ }
+ catch(error) {
+ return opera.postError('Error parsing feed.');
+ }
+ }
+ else {
+ xmlDoc = xhr.responseXML;
+ }
+
var title = xmlDoc.querySelector('title');
_data.title = title.textContent || "No title";
@@ -126,7 +140,7 @@
return false;
};
- _processData( this.responseXML );
+ _processData( this );
_updateTimer = setTimeout( _XHRFeed, 1000*120 );
}
xhr.send(null);

0 comments on commit 8f46422

Please sign in to comment.