0
votes

I wrote a little local-running HTML/Ajax-Page for visual output. The script is testing some proxy-servers by calling a local PHP-Script via AJAX in intervals.

The PHP-Script is testing the response-time of random Proxy-IPs via PHP's cURL-function and is sending the response-infos back to the HTML-Page via Ajax for visual output. Working fine so far..

Now I have add a little button to my HTML-Page. The button executes a AJAX-request to my PHP-Script again. The PHP-Script is calling exec("PATH_TO_CHROME" --params ) to start my chrome-browser with a given url and should give back an ajax-response, too. Nothing special, just give the info to my HTML/Ajax-page, that the command was successful executed. I need a response to reactivate the AJAX-functionality, because I block the AJAX-functions after every call until I get a response.

The problem: The browser (Chrome) opens, but I don't get any AJAX-response, until i close the browser (even if I echo the AJAX-response before the exec(..); flush/ob_flush doesn't help). Seems that the executed browser blocks the PHP-process while running. Is there a way to prevent this behavior?

1

1 Answers

0
votes

Okay, found a solution by myself.

Instead of exec(..) I could use the Windows build-in function "WScript.Shell".

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run('PATH_TO_CHROME --params url', 3, false);

This works asynchronously (due the "false"-Parameter) and PHP is sending the additional Ajax-Response while opening the browser.