Add a better implementation of promises

Calling .then() didn't work in my original solution
because of the old jQuery version. Switching to .pipe()
solved the problem without having to create a new Deferred