Want to show “loading…” in PHP page

元气小坏坏 提交于 2019-12-21 21:35:34

问题


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......


回答1:


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

I hope this helps.




回答2:


Learn to use JQuery, JQuery UI. It isn't that hard! What I think you need to learn is the following for your problem:

  • .click()
  • .html()
  • jQuery.get()


来源:https://stackoverflow.com/questions/4803983/want-to-show-loading-in-php-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!