Resolve "Uncaught TypeError: undefined is not a function" error when both *timeout* and *failure* are defined. Fixes #1817 [stanleyhlng]