Debugging AJAX + another Bloglines gripe

[imported from Bloglines]

I’m playing with AJAX at the moment and found some useful techniques/tools…

Currently I’m serving different formats depending on what browser is being used.

e.g

for browsers which support application/xhtml+xml / XHTML 1.x, they get:

mime = application/xhtml+xml

doc start =

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

for other browsers, they get:
mime = text/html
doc start =

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Anyway, I have a javascript which creates a global variable called mimexml so that other parts of the script know how I’ve served the original page (there may be a better way to do this)

I’m using the prototype.js AJAX library and the following routine to update a div:

function showResponse(originalRequest)
{
if (mimexml) {
c =     document.getElementById('ici_ajaxresult');
removeChildNodes(c);
c.appendChild(document.importNode(
originalRequest.responseXML.documentElement.getElementsByTagName('div')[0],
true));
} else {
c =     document.getElementById('ici_ajaxresult');
c.innerHTML =     originalRequest.responseText;
}
}

What I wanted to do was “view source” but of the rendered page, after the javascript had done its stuff… (both in IE and FF)

Two useful tools:

Jennifer Madden’s View Rendered Source (Firefox Extension)

Bill Friedrich’s View Rendered Source (IE Utility)

Bloglines gripe: the editor is really very flakey (adding/editing a blog entry.. formatting stuff, pasting, view source, etc)

Leave a Reply