I've got two scripts that run separate from each other but are both used on the same page. One generates a PDF, and the other makes a call to an external API. Both scripts use curl.
On the page, an AJAX request is used to call the PHP script that calls the API. It also displays links the user can click to generate the PDF. The problem is when I try to generate the PDF, it has to wait until the other script that calls the API finishes. When there's a connection problem, that means long waits for the user.
From what I can tell, this happens because both scripts use curl, and the PDF one has to wait for the API one to finish it's curl call. I only have access to edit the API script. What I've done at the moment is set a timeout of 10 seconds to limit how long the user has to wait for the other script to finish, but I'd like to make it work so that the one script doesn't need to wait for the other to finish.
Is that possible with PHP? I tried switching from curl to file_get_contents, but it still waits for the other script to finish. And I assume a solution like curl_multi wouldn't help here since I can't edit one of the scripts.