function open_appointment(id)
{
save_method = 'open_appointment';
$('#form_open_appointment')[0].reset(); // reset form on modals
$('.form-group').removeClass('has-error'); // clear error class
$('.help-block').empty(); // clear error string
//Ajax Load data from ajax
$.ajax({
url : "<?php echo site_url('ReceptionistController/ajax_edit_appointment')?>/" + id,
type: "GET",
dataType: "JSON",
success: function(data)
{
$.ajax({
url : "<?php echo site_url('ReceptionistController/ajax_edit_patient')?>/" +data.ap_patient,
type: "GET",
dataType: "JSON",
success: function(data)
{
$('[name="pt_id"]').val(data.pt_id);
$('[name="pt_name"]').val(data.pt_name);
$('[name="pt_dob"]').val(data.pt_dob);
$('[name="pt_sex"]').val(data.pt_sex);
$('[name="pt_contact"]').val(data.pt_contact);
$('[name="pt_email"]').val(data.pt_email);
$('[name="pt_address"]').val(data.pt_address);
id=parseInt(id);
var next_id=id+1;
var previous_id=id-1;
//button to call back the function with next id
$('#next_patient').click(function() {
alert("next"+next_id);
open_appointment(next_id);
});
//button to call back the function with previous id
$('#previous_patient').click(function() {
alert("next"+next_id);
open_appointment(previous_id);
});
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Failed');
}
});
$('#modal_open_appointment').modal('show'); // show bootstrap modal when complete loaded
$('.modal-title').text('Open Appointment'); // Set title to Bootstrap modal title
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error get data from ajax');
}
});
}
工作的下一个按钮的功能将被重新装入下一个ID的点击(比如ID 1),但问题是下一步按钮的功能加载两个时间的第二次点击(当前ID和下一个ID说ID 1和2)和第三次点击它加载三次(负载ID说ID 1 ID 2和ID 3)。我想这是只有在每个最后一个ID点击Ajax调用不上用onclick
事件调用堆栈功能(点击)我觉得 –