Novak Djokovic survived a tricky encounter with British wild card Jacob Fearnley to reach the Wimbledon third round.