dongtun2459 2014-01-19 16:59
浏览 44
已采纳

完整更新页面时,jQuery OnClick运行外部页面

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.

Thanks

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"); });
    });

});
</script>

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

2条回答 默认 最新

  • douxing8323 2014-01-19 17:11
    关注

    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
    $("#status").html("");
    }
    </script>
    
    <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:

    $("#status").html("Completed");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法