从PHP调用Ajax来执行单独的PHP; 有危险吗?

I'm trying to execute a php-script in the background, so the user doen't have to wait for the processing to be done.

In PHP I can call a javascript:

?>
<script>
window.top.hdReq();
</script>
<?

which calls a javascript XMLHttpRequest to trigger the php script. I'm not interested in any response from that script.

I know it might be a bit of a workaround, but... it works like a charm, for now :-) And since I don't know on what kind of server the website ends up, I have to look for a way that works on all occasions.

My question, before I write the entire php-script: might there be any dangers or problems involved in executing it this way? (Besides the user not allowing javascript, but in that case the entire website doen't work :-)

There is no real danger in doing it this way...

Be sure to sanitize any input you post/send to the php script and be sure to pass a token to ensure it's actually your code sending the requests to it.

No danger. But think about what this script will do. If it will do something which require much time, then when use close the page and script did not finish his job, it may happen to be killed by Apache untill job is not completed.