creating method to save in DB using Ajax