add beforesend event to xhr. fixes 1397