Making a Server Request (^) ❘ 187
// Swap out the flag image
$('div#addressCountryWrapper img').attr({
alt : xml.find('name'),
src : 'flags/' + iso2.toLowerCase() + '.png'
});
The element is located by querying the DOM for a
element with an id attribute
having the value addressCountryWrapper and then fi nding the
element within. Then the ![]()
element’s src and alt attributes are set using jQuery’s attr() method, and the path for the fl ag is
defi ned, taking into account the structure of fi les in this book’s source code download materials.
Then the fi lename is appended, and the ISO2 code is converted to lowercase because each fl ag image
is named using lowercase characters. This may not be a problem for some servers, such as Windows
or some Mac servers that are case-insensitive, but UNIX and Linux servers, including some Mac
servers (depending on how the Macs have been formatted), are case-sensitive, and having the incor-
rect case for the fi lename would cause the image to fail to load.
The next step is to remove all state options. First, query for the
having the value addressCountryWrapper and then fi nding the
element’s src and alt attributes are set using jQuery’s attr() method, and the path for the fl ag is
defi ned, taking into account the structure of fi les in this book’s source code download materials.
Then the fi lename is appended, and the ISO2 code is converted to lowercase because each fl ag image
is named using lowercase characters. This may not be a problem for some servers, such as Windows
or some Mac servers that are case-insensitive, but UNIX and Linux servers, including some Mac
servers (depending on how the Macs have been formatted), are case-sensitive, and having the incor-
rect case for the fi lename would cause the image to fail to load.
The next step is to remove all state options. First, query for the