corrected the Deferred defn. for elasticssearch.js

Oftentimes the existing code is causing `uncaught errors` with _.isUndefined. 

All other backends are using this `typeof jQuery !== undefined` and it seems to be working fine without problems.

Correcting the code to be compatible with all other backends and also eliminate the uncaught error with async exec.