【问题标题】:fancybox onclick get id is not being passedfancybox onclick 获取 id 没有被传递
【发布时间】:2013-01-15 05:19:20
【问题描述】:

所以当您单击链接时,它会打开一个模式框并将 theid 发送到文件 requestajax.php,唯一的问题是我不知道如何获取 theid 的值。 theid 是 id 值 $row['id'] 因为它是一个循环,有不同的 id。如果我将 var theid 放在 .fancybox 之外,则它不会被通过。有什么想法吗?

这是我的代码:

$(".cobox").fancybox({

    href : 'requestajax.php',
    type: 'ajax',   
    ajax : {
        type    : "GET",

        data    : {cid:theid},
        success: function(){ 
  }
    }


});

这里是 html/php :

<a id="<?=$row['id'];?>" class="cobox" href="#inline">

【问题讨论】:

    标签: php javascript jquery fancybox fancybox-2


    【解决方案1】:

    通过编写此代码使其工作:

    $(".cobox").click(function(e) {
       var thid = this.id;
       $.fancybox({
        href : 'requestajax.php',
        type: 'ajax',   
        ajax : {
            type    : "GET",
    
            data    : {cid:thid},
            success: function(){ 
      }
        }
    
    
    });  
    
                });
    

    【讨论】:

      猜你喜欢
      • 2011-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-25
      • 1970-01-01
      相关资源
      最近更新 更多