consider using xhr.onload?