我有文本框郵政數組到PHP使用jQuery
<input type="text" name="txt[]" id"txt[]" value="test 1" />
<input type="text" name="txt[]" id"txt[]" value="test 2" />
<input type="text" name="txt[]" id"txt[]" value="test 3" />
的陣列,並希望使用jquery發佈此數組PHP文件:
$('#submit').click(function() {
$.ajax({
type : 'POST',
url : '<?php echo site_url('projects/create'); ?>',
data: {
txt: $('#txt').val()
},
success:function (data) {
$("#log_msg").html(data);
}
});
});
但它返回undefined
您使用的是選擇#這是id。而一個文本框的id是「txt []」 –