finished ajax implementation of apicall