Putting elements into the form and sending them just seems to be hacked, and I don’t feel comfortable using it.
When you use these types of things, I think you take a little risk, the next versions of browsers may simply not support them.
In addition, I pass complex arrays as parameters in my ajax call to the server, and it is not easy to convert them all to an html form if I do not serialize the arrays in the hidden element and unesterialize it on the server side, but that is all too complicated.
What I did was when the ajax call was made, the server saves the output in the session, then it returns a unique key for this value, another page on the server will simply echo when this key is indicated to it as input,
Thus, the user clicks on something, then an ajax call is made, then the server saves it in the session, then the user clicks the download link, and then the server deletes this session.
This may not be the most perfect solution on purpose, since the user needs to double-click, but it seems more standard to me.
source share