I have read that in his "Fundamenta Nova Theoriae Functionum Ellipticarum", Jacobi managed to solve the equation \begin{align} \frac{dx}{\sqrt{(1-x^2)(1-k^2x^2)}} = \frac{pdy}{\sqrt{(1-y^2)(1-l^2y^2)}} \end{align} for any odd prime $p$, by making a substitution $y=U(x)/V(x)$, where $U(x)$ and $V(x)$ are polynomials, and as a result he was able to get an algebraic relation between $k$ and $l$ (a modular equation).
Did Jacobi know this substitution would work or did he just guess it and found that it worked by laborious trial and error? Using what we know today, could we come up with this substitution and derive the relation between $k$ and $l$ more easily?