Lastfm accepts only utf-8 charset.
So replace:
doc.write('<form method="post" action="' + apiUrl + '" id="form">');
to
doc.write('<form method="post" action="' + apiUrl + '" id="form" accept-charset="UTF-8"><input name="iehack" type="hidden" value="☠" />');
thx!