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条)

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂