Moved the setting of the request header after opening the xhr