donglu9134 2011-04-11 10:35
浏览 22
已采纳

当事情发生时如何使用php脚本,ajax?

I am building a comment system. so, I have a php page that displays one comment. now I have a php Want to load all comments in a single page. how do I take the data from file A and display it in file B?

Furthermore and more importantly, I have a upvote button, when you press it some script needs to get executed, I can write that script, but than how can I make it happen?

I really don't know ajax but somehow I have a feeling it has something to do with this... how do i do this?

I can only think of two methods for first one, and nothing for second one. I thought of including the HTML using php "include" or use Iframes, both solutions seem weird...

I Have programmed in php for a while now, but this is the first thing I actually do with it...

Thanks in advance, Fingerman.

  • 写回答

2条回答 默认 最新

  • dqzuo0327 2011-04-11 11:34
    关注

    First of all to create a upvote button do something like:

    <img src=".." id='upvoteButton' />
    

    And Use JQuery with AJAX like:

    $("#upvoteButton").live('click', function(){
            postData="data="+value; /* Data that you may want to pass to your script */
            $.ajax({
                type: "GET",
                url: "yourSecript.php",
                async: true, /* If set to non-async, browser shows page as "Loading.."*/
                cache: false,
                data: postData,
                success: function(data){ 
                }
            });
            return false;
        });
    

    Please let me know if you are not clear....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化