I'm learning a bit with JavaScript and PHP.
The case is that I have a form ( form
). Once filled in you have two processes.
One is PHP, which collects the $POST
of the html with if(isset($_POST['submit']))
and processes them to export it to text to a local fixed route automatically (no download).
Once it's over, it throws a header to the results page.
And on the other hand, I have a onsubmit
in form
, which triggers a JavaScript, which collects the entire document and generates a PDF using JSPDF. This same JavaScript, uses JQuery - AJAX to send the information to another processing PHP and I store it locally (automatically without headers
, it saves it in a specific route).
The concrete issue is, in doing so, in two ways, many times one ends before the other and the processing of either does not end and generates a corrupt file or fails to generate it (PDF corrupt is the usual).
The question is, how could I shoot so that I would first do the part with java and then the if(isset($_POST['submit']))
of PHP?
Or some way to unify the process and not go 'each one on his own'.
There's something I do not know, like an event or similar ...
Partially I solved the problem in the first part, doing a sleep
before sending the header
to the results page (wait x seconds), so just process the second part and without problem, but not what I see optimal.
Any help is appreciated. Thanks.