我正在使用jquery在模态中添加文本框,然后将值ajax存储到我的数据库中,但我很惊讶地看到相同的代码在本地PC上正常工作,而同样不能正常工作。这是我的代码
模态(表格)
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return THE_SPACING_AMOUNT
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return SPACING_BETWEEN_ROWS
}
jquery
<form class="form-horizontal" role="form" id="form-head_sub">
<div class="form-group">
<label class="control-label col-sm-3" for="">Head Name</label>
<div class="col-sm-9">
<input type="text" name="head" class="form-control" id="Head-name" placeholder="Enter Head Name" required="">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="">Sub Head</label>
<div class="col-sm-9">
<input type="text" name="subhead[]" class="sub" id="sub-head" placeholder="Enter Sub Head Name" required="">
</div>
<label class="control-label col-sm-3" for=""> </label>
<div class="col-sm-9" id="target">
</div>
</div>
<div id="container"></div>
<input type="button" id="add" value='add'/>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success" name="save">save
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
</button>
</div>
</div>
</form>
AJAX页面
$(document).on('submit','#form-head_sub', function(event){
event.preventDefault();
var head = $('#Head-name').val();
var allValue = new Array();
$('.sub').each(function(){
allValue.push( $(this).val() );
});
$.ajax({
url: 'data/add_headsub.php',
type: 'post',
data: {
head:head,
subhead:allValue,
},
.....
除了动态文本框值
之外,所有值都插入数据库中