Error when sending messages caused empty table to be returned when using Ajax