我有一个数据库MySQL。我们有个人详细信息HTML表与单选按钮。我想使用AJAX和PHP修改表数据。选中单选按钮后,单击修改按钮,然后检查表行应在BOOTSTRAP MODAL中打开。它是从表中检索值,但它没有显示在MODAL.i中需要一个代码后AJAX获得成功MODAL应该打开但这里Modal不工作FOrm只显示 两个文件:
两个文件: 1)modify.php
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modifyModal" id="emp_modify">Modify</button>
$.ajax({
type: "POST",
url: 'modify1.php',
data: {option:'modify',empID:id},
success: function (data) { //after AJAX get succes MOdal SHould open
//$('#emp_modify1').html(data);
$("#getCode").html(data);
$("#getCodeModal").modal('show');
}
});//end of ajax
}
else {
alert("Select a row first");
}
})
});
</script>
</body>
2)modify1.php
<form class="form-horizontal" id="edit" name="edit">
<div class="form-group">
<input id="id" name="edit" class="form-control" type="hidden" value="<?php echo $elements['emp_id']; ?>"
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1"> Name </label>
<div class="col-sm-9">
<input id="uid" name="edit" class="form-control" type="text" value="<?php echo $elements['name']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1">gender</label>
<div class="col-sm-9">
<input id="semail" name="edit" class="form-control" type="text" value="<?php echo $elements['gender']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1">gender </label>
<div class="col-sm-9">
<input id="semail" name="edit" class="form-control" type="text" value="<?php echo $elements['gender']; ?>">
</div>
</div>
</form>
答案 0 :(得分:0)
你必须在modify1.php中回显完整的html元素
echo '<form class="form-horizontal" id="edit" name="edit">
<div class="form-group">
<input id="id" name="edit" class="form-control" type="hidden" value="' . $elements['emp_id'] . '"
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1"> Name </label>
<div class="col-sm-9">
<input id="uid" name="edit" class="form-control" type="text" value="' . $elements['name'] . '">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1">gender</label>
<div class="col-sm-9">
<input id="semail" name="edit" class="form-control" type="text" value="' . $elements['gender'] . '">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="form-field-1">gender </label>
<div class="col-sm-9">
<input id="semail" name="edit" class="form-control" type="text" value="' . $elements['gender'] . '">
</div>
</div>
</form>';