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?

  • You can use the jq template. That is, you will have an ajax request that returns data and you just need to substitute this data in the jq template. And in the template itself will be the structure of the new form. - batya

1 answer 1

removeChild + XMLHttpRequest + innerHTML will help you to create this terrible idea.