I have jquery code that appends a field into a form. When I submit that form, the fields that get appended are not available to PHP. Is there anything special I have to do to pick these fields up? Here is the code:
$(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>
A dump of the POST variable in php will show all values input in the form except the ones that were added with jquery.