想显示“加载中....."在 PHP 页面中 [英] Want to show "loading....." in PHP page

查看:33
本文介绍了想显示“加载中....."在 PHP 页面中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 PHP 开发一个需要以下功能的网页:1. 当用户点击SayThanks"时,它应该改为Done!".2.同时我想在indexController中调用一个动作.3.这时候我要显示loading...."4.当前页面有很多动态内容,也不应该改变.

I am developing a web-page in PHP that needs following functionality: 1. When User click on "Say Thanks" it should be changed with "Done!". 2. At the same time I want to call an action in indexController. 3. At this time I want to show "loading...." 4. The current page has a lot of dynamic contents that should also not change.

请建议我应该怎么做才能完成上述任务......

Please suggest me what should I do to complete above tasks......

推荐答案

我认为您需要 AJAX 调用.我通常这样做是为了加载评论等,当你按下更多"时.在我的例子中,有一个空的 div 和一个 <a> 标签,带有指向评论视图的链接(带有单独的操作,ofc).然后我使用 jQuery 来实现 AJAX 魔法:

I figure you need an AJAX call. I usually do that for loading comments and such when you press "more". In my case, there's an empty div and an <a> tag with the link to the comments view (with a separate action, ofc). Then I use jQuery for the AJAX magic:

$(function() { 
    $("a.CommentsListBtn").click(function() { 
        var tmpHref = $(this).attr("href");
        var tmpLayer = $(this).parent().children("div.CommentsList");
        tmpLayer.load(tmpHref, function() {
            tmpLayer.stop().slideDown("medium");
        });
        return false;
    });
});

我希望这会有所帮助.

这篇关于想显示“加载中....."在 PHP 页面中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆