moving ajax to api model