Add new contents to web page automatically

Add new contents to web page automatically

Greetings!

I am new to jquery but am under the impression that it will help me achieve the following goal. I have searched this site and googled for a solution but did not succeed.

I have a web page that is going to kick off a backend script (perl) with a click of a button.The script consists of a bunch of sql queries each returning a result (success/fail). The script should be running until either finished or if one of the steps fails. On success i want the html page to be updated in more or less real time like "starting" [wait for processing] [append] "step 1: done" [wait for processing] [append] "step 2: done" [wait again]. On fail i want it to be updated with "step 3: fail. continue anyway? [ok button]". If ok button is pressed, i'd like the script to continue to step 4 etc. An easy way to think of this is when you install a program the process runs and gives you an update of what's going on until it runs into an issue, at which point it asks you for your input.

What do i need to do so the html page automatically shows new contents when the step is finished executing? I have no problems refreshing it every 5 seconds with the meta tag, but then i would need to set it to not refresh if the step fails.

Could someone please point me in the right direction for this? All help is much appreciated!

Thank you in advance!