In the traditional precision machining, it is easy to introduce positioning error because of the separation of the machining and the measurement. In order to solve this problem, an online measurement technique for aspheric grinding has been put forward. It measured the workpiece with sensor which was fixed to the high-precision machine tool. It processed data with the algorithm of Two-dimensional weighted average filtering and curve fitting based on Gauss-Newton and Levenberg-Marquardt least-square method. The experimental results indicated that the fitting residual error was less than 3×10-6 mm. In the grinding process, the measurement error was of the order of the magnitude of 10-3 mm. It can be concluded that the technique measures the surface exactly, and improves the machining accuracy effectively by providing accurate data for compensation.