表格不发布数据

时间:2014-07-08 07:06:51

标签: php jquery html

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

我在页面上有两个表单,一个帖子很好但另一个不发布任何内容:

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

通过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();

});

我现在只是在做print_r($_POST),但它只是提出了Array ( )

我已经检查了jQuery是否放入了值,而且确实是这样(firefox inspector pic):

编辑:

另一种形式:

<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 个答案:

答案 0 :(得分:-2)

更新:

$('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();

});

$('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();

});

您使用链接时不会阻止链接。

相关问题