Ensure that res exists before making a call to it.
Merge pull request #31 from thomasbiddle/fix_res_is_undefined

Fix for when .text() is called on an undefined object.