0

I have a PHP file that takes a while to run, it has several parts to it, Is there a way to send a command back to javascript after part of the PHP file has been completed?

5
  • Have you looked into AJAX at all? Commented Feb 7, 2013 at 9:57
  • Yeah, I used AJAX to have a loading gif, but I want incremental updates to my text. So the person knows whats happening. Commented Feb 7, 2013 at 9:58
  • By the sounds of what you want to achieve (incremental updating), you'll have to use a series of AJAX requests. Commented Feb 7, 2013 at 10:00
  • Try working with output buffering (ob). This post might be helpful stackoverflow.com/questions/6313159/… Commented Feb 7, 2013 at 10:00
  • You can call some page that will start the long running script and returns a filename where that scripts output will be, the next ajax call would be to that filename as your long running script appends to that file. When done it puts "I am done" or something at the last line so your JavaScript knows not to make any more requests and has the full content. Once every so often delete all the files created in this way. Commented Feb 7, 2013 at 10:09

1 Answer 1

0

PHP runs in server side and javascript in client side.

First PHP runs in server and once it is completed it sends output to client (browser)

You can use AJAX for your requirement

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.