This paper presents a local online planning method based on hp adaptive pseudospectral method to address the cooperative trajectory planning of UCAV formation in uncertain environment. First, through analyzing attacking process of UCAV formation, the cooperative trajectory planning model is built up by taking UCAV threat, task time and the number of collision and the error of ordered time as the object function. Second, in order to solve the online cooperative trajectory planning, according to real-time environment information and offline planning data, the local planning method based on hp adaptive pseudospectral method is proposed during optimizing time slice. Last but not least, the simulation results for offline and online cooperative trajectory show that the proposed method is valid and can provide cooperative trajectory with high precise control and state information.