dongtanliefang8765 2013-11-12 22:35
浏览 39

使用jQuery / AJAX进行CakePHP动态搜索

currently I have a search that calls once a Controller Action with requestAction and returns a data array, then I use foreach to list in a table.. So, how could I implant a button that refreshs the table without leave the page?

thanks

Edited: I have a element from a View called table.ctp, inside there is: $products = $this->requestAction('/products/getAll'); then

foreach ($products as $product){
    echo $product['Product']['Name'];
}

/ender all my products that came from /products/getAll.

Controller products, action getAll():

function getAll(){
    return $this->Product->getProducts();
}

Model (Product.php), the function getProducts() returns $this->find('all')

I want to have an input in table.ctp that when I click a button, he will refresh the table with AJAX.. I tried this:

<script type="text/javascript">
    $(document).ready(function(){
        $('#click').click(function(){
            $.ajax({
                type: "POST",
                url: '',  
                success: function(data){

                }
            });
        });
    });
</script>

but I have no idea how to proceed, which URL call, and this way is right..

thanks!

  • 写回答

1条回答 默认 最新

  • doutuo1939 2013-11-13 14:18
    关注

    I answered that question here, hope it fulfills your expectations.

    Ask for more help... ;)

    D.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b