JeffVader JeffVader - 4 months ago 18x
PHP Question

jQuery OnClick Run External Page when complete update page

I know it's possible using jQuery to load/run an external web page. In the past I've used something like:

$.ajax({ url : 'test.php'})

What's I'm looking to do now is when a user click the 'GO' button an external PHP is called. Whilst it's running the main page should show 'please wait' and once the external script has finished the main page should update to show completed.

The php page I'm calling is actually running a shell script and I get no feedback from it. However the page runs and completes fine.

Is there anyway I can tell if it's still running and then update the main page ?

I'd be grateful if some one could point me in the right direction.


UPDATE based on answer below.

<script type="text/javascript">
$(document).ready(function() {

$("#update").click(function() {
$("#status").html("<p>Please Wait!</p>");
$.ajax({ url : 'test.php' }).done(function() { $("#status").html("Completed"); });


<span id="status"><span>
<input type="button" id="update" value="Check for Update" />


Lets take an example:

you have this html:

<script type="text/javascript">
function updatecheck()
//Shows Please Wait in Status
$("#status").html("<p>Please Wait!</p>");
$.ajax({ url : 'test.php'})
.done(function() {
//Hides Status

<span id="status"><span>
<input type="button" onclick="updatecheck()" value="Check for Update" />

.done will be triggered when the ajax request will be completed and it will hide the value.

In case you want to show completed instead of hiding value just use: