Fixed headless client for deferred jQuery

jQuery's .when didn't work. Until now.