Since we have no clue what your program is doing or exactly what you are trying to accomplish, here is a shot in the dark…
Experimented some with using ajax to run php. Not the best approach as can be resource heavy. Something like:
function myAjax() {
$.ajax({
url...