[Greasemonkey] Bug in GM_xmlhttpRequest?

Mark Pilgrim pilgrim at gmail.com
Wed May 4 11:36:06 EDT 2005


I'm calling GM_xmlhttpRequest and my onload callback function is
getting called twice.  Is this expected behavior?

code snippet:

GM_xmlhttpRequest({
    method: 'GET',
    url: 'http://greaseblog.blogspot.com/atom.xml',
    headers: {
        'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
        'Accept': 'application/atom+xml,application/xml,text/xml',
    },
    onload: function(responseDetails) {
        var parser = new DOMParser();
        var dom = parser.parseFromString(responseDetails.responseText,
            "application/xml");
        var entries = dom.getElementsByTagName('entry');
        var title, p;
        for (var i in entries) {
            title = entries[i].getElementsByTagName('title')[0];
            p = document.createElement('p');
            p.appendChild(document.createTextNode(title.textContent));
            document.body.appendChild(p);
        }
    }
});



-- 
Cheers,
-Mark


More information about the Greasemonkey mailing list