dongmu1390 2014-07-08 07:06 采纳率: 100%
浏览 48
已采纳

表格不发布数据

JSfiddle: http://jsfiddle.net/NqaZ2/4/

I have two forms on a page, One posts fine but the other does not post anything:

<form id="comment-oa" action="" method="post">
    <input type="hidden" name="key" value="coa" />
    <input type="hidden" name="action" value="" />
    <input type="hidden" name="value" value="" />
</form>

Its being submitted through jquery:

$('a[data-role="fc-delete"]').click(function(){
    var id = $(this).parent().parent().parent().parent().attr('id'),
        spl = id.split("-");

    $('#comment-oa input[name="action"]').attr('value', "delete");
    $('#comment-oa input[name="value"]').attr('value', spl[0]);
    $('#comment-oa').submit();

});

and I'm simply just doing print_r($_POST) at the moment, but it just comes up with Array ( ).

I've checked whether jQuery puts values in and it does (firefox inspector pic):

EDIT:

The other form:

<form action="" method="post">
    <textarea name="comment"></textarea>
    <input type="hidden" name="reply-id" value="" />
    <input type="submit" value="Post comment" />
    <input type="button" value="cancel" style="display: none;" />
</form>
  • 写回答

1条回答 默认 最新

  • doujin8673 2014-07-08 07:20
    关注

    Update:

    $('a[data-role="fc-delete"]').click(function(){
        var id = $(this).parent().parent().parent().parent().attr('id'),
            spl = id.split("-");
    
        $('#comment-oa input[name="action"]').attr('value', "delete");
        $('#comment-oa input[name="value"]').attr('value', spl[0]);
        $('#comment-oa').submit();
    
    });
    

    to

    $('a[data-role="fc-delete"]').click(function(e){
    e.preventDefault();
        var id = $(this).parent().parent().parent().parent().attr('id'),
            spl = id.split("-");
    
        $('#comment-oa input[name="action"]').attr('value', "delete");
        $('#comment-oa input[name="value"]').attr('value', spl[0]);
        $('#comment-oa').submit();
    
    });
    

    Your using a link without preventing it form well - linking.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大