Ajax 'works' but javascript responses don't