剑圣 2015-07-29 11:47:14 3634次浏览 1条回复 0 0 0

我想通过jquery ajax实现: 点击按钮后,后台数据库通过./index.php?r=admin/default/update&id=<?php echo $i->id; ?>这个链接修改某个字段。 前端按钮点击后消失变成提示文字。

请问,我该怎么写jquery?

  • 回复于 2015-07-29 12:41 举报

    $.get(<?= Url::toRoute(['/admin/default/update','id'=>$i->id]) ?>,function(json){ alert(json);//fadeout,html(txt) });

    6 条回复
    回复于 2015-07-29 13:44 回复

    Url::toRoute是干什么用的?

    回复于 2015-07-29 15:12 回复

    生成url用的。

    回复于 2015-07-29 15:18 回复

    这个是...

    回复于 2015-07-30 11:06 回复

    @╃巡洋艦㊣

    $("button").click(function(){
        $.get("./index.php?r=admin/default/update",
        {
          id:"1"
        },
        function(){
            $("#btn1").each(function(){
            $(this).replaceWith('审核通过');
          });
        });
    });
    

    我把一个按钮的功能实现了,要想不同的button id传不同的id值给jq,有什么好办法吗?

    回复于 2015-07-30 11:34 回复

    $("button").click(function(){
     var id = $(this).attr("data-id");
    $.get("./index.php?r=admin/default/update",
    {
      id:id
    },
    function(){
        $("#btn1").each(function(){
        $(this).replaceWith('审核通过');
      });
    });
    });
    ...
    <button data-id='1' >
    <button data-id='2' >
    <button data-id='3' >
    
    回复于 2015-07-30 15:02 回复

    奥,我明白了,谢谢这位大神啦!也谢谢我们的舰长!

您需要登录后才可以回复。登录 | 立即注册