move ajax url building logic to js