0

I need to run a php script (site crawler) on submit button click without a page reload. After the background script run, A confirmation / alert popup should appear that the site crawler is ended. Any Ideas Please?

3

2 Answers 2

1

Basically the idea goes like this:

  • you send and XHR call to server and execute script
  • script checks if there is already a background process
    • if there is one, return the status code
    • if on background script running: script forks itself , returns an "OK" response and start to do the work
  • with a different XHR call you repeatedly check if script has finished
  • when the server-side script has finished running, you gather the results and diplay in the page

To simplify the interaction with server, you might want to use some of the XHR libraries. I would avoid suggest to avoid slapping on jquery unless you are actually already using it for something else.

As for "how to know when background script has finished" : i think the best way would be for that script to create a file, which contains

  • when running: -1
  • when finished: 0
  • when error: positive number
Sign up to request clarification or add additional context in comments.

Comments

0

Jquery + AJAX could make your job easier. Read this tutorial on how to achieve the result:

AJAX+ jQuery Tutorial

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.