There is a project in php. All pages are static, usually with several forms on the page, each with its own submit. Each submit causes the page to reload. Each form is built by its own separate function using the echo operator.
It is necessary to rewrite the most critical pieces of the project by removing the restart of the entire page by submit. With the execution of the action, everything is clear, using ajax helps solve the problem. But some forms have quite complex rendering logic and I would like to use the existing php-functions for this. Is it possible to somehow somehow remove the form from the page on js, and then get its new html-code from php again to display?