0
我在codeigniter框架中使用jquery ajax來加載彈出模式按鈕單擊。我將ajax請求傳遞給控制器中的某個函數,並接收一些數據,這些數據應該以我彈出的模式顯示。模式標籤的數量取決於ajax請求接收的數組大小。使用for循環插入多個標籤字段
我不知道如何做到這一點。但我嘗試將接收數組的大小傳遞給彈出模式上創建的窗體中的隱藏類型輸入字段。
以下是我的javascript。
<script type="text/javascript">
$(document).ready(function() {
$(document).on('click','#btn_more', function() {
empId = $('#employeeId').html();
fiter_employees(empId);
});
function fiter_employees(empId){
var empSet ={
empId: empId,
method: 'ajax'
};
var empSentUrl = 'http://localhost/eventmanagementsystem/index.php/employee/get_emp_positions';
$.ajax({
type: 'POST',
dataType: 'json',
url: empSentUrl,
data: empSet,
success: function(data){
$('#modal_pkg1').html(data.empPosition.length)
$('#employeePositions').modal();
}
});
}
});
在我彈出的模式,我用它沒有成功以下代碼。
<div id="employeePositions" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Employee Name :</h4><br/>
<form>
<?php
for ($i=0; $i < ?>
<input type="hidden" id="modal_pkg1" value="modal_pkg1" />
<?php
; $i++) { ?>
<h4 class="modal-title" id="event_name"></h4>
<?php
} ?>
</form>
有人能告訴我這樣做,請正確我...
感謝ü您的快速性反應。 – Christeen