1

我有将字段附加到表单中的 jquery 代码。当我提交该表单时,附加的字段对 PHP 不可用。我有什么特别需要做的才能选择这些字段吗?这是代码:

$(document).ready(function() {
   window.unique = 0;

    //hides alert
    $("hide").click(function(){
     $("#alert").hide();
    });


     $(document).on('click', '#toggle_header', function(){
         window.unique++
            $("#header_list").append("<li><input type='text' name='header_name" + unique  + "' placeholder='name'><input type='text' name='header_value" + unique  + "' placeholder='value'><a href='#' id='toggle_header_remove'><i class='icon-remove'></i></a></li>");
     });







     $(document).on('click', '#submit_query', function() {
        $.ajax({
            url: 'index.php',
            type: 'post',
            data: $(this).serialize(),
            cache: false,
            dataType: 'json',
            success: function(data) {
            }
            })
    })




});



<form method='post' action='index.php' id='main'>
                <input class="span5" id="appendedInputButtons" type="text" name='url'>
                <button class='btn btn-inverse' id='submit_query'>GET</button>

            </div>
            </br><a href='#' id='toggle_header'>add header<i class='icon-plus'></i></a>
            </br>
            <ol id='header_list'>
            </ol>
</form>

php 中 POST 变量的转储将显示表单中输入的所有值,除了使用 jquery 添加的值。

4

0 回答 0