I am writing an application that looks up addresses based on post
codes.  I have modified the perl script that the database provider
supplied to output XML, and now I need to write some client side
javascript to parse the results.

At the moment I'm at a very early stage and thought it would be a good
idea to process the XML with jquery but I have run into something of a
snag.

var addressLookupScript = '/cgi-bin/getAddress.pl'

function listAddresses (xml)
{
        console.log (xml);
        $('address', xml.responseXML).each (function (index)
        {
                console.log (index);
        });
}

$(document).ready (function ()
{
        var addressField = $('#address');
        $('#lookup').click (function ()
        {
                $.ajax ({
                        type            : 'GET',
                        dataType        : 'xml',
                        url                     : addressLookupScript + 
'?address=' + addressField.val (),
                        success         : function (response) {listAddresses 
(response);}
                });
        });
});

As you can see the script doesn't do very much yet, it just loops over
the returned XML and outputs an index number of each loop.

I found that this approach works perfectly in FireFox, but when I
tried to run the same code in Internet Explorer, nothing happened.
Firebug Lite just logged an empty line at the console.log (xml) line
and didn't execute the loop.

I think that logically my code is correct, but there is something
about it that IE doesn't like.  If you can shed some light on this I'd
appreciate a fix or a workaround of some sort.

Reply via email to