Я пытаюсь обновить и получить обновленную строку в то время из базы данных в Ajax вызоваUpdate и получить данные в том же АЯКС вызов
JS в готовой функции
$("button[name='teacher_lock_exam']").on(ace.click_event, function() {
var current_exams_id = $(this).attr('id');
bootbox.confirm("Are you sure you want to lock the exam? <br/><br/>" +
"Locked exam cannot be modified until exam committee unlock it.", function (result) {
if (result) {
lock_exam(current_exams_id);
bootbox.alert("Your Exam has been Locked !<br/><br/> Contact with Exam committee to modify that exam again.");
}
});
});
function lock_exam(current_exams_id) {
$.ajax({
url: "teacher_internal_exam_management/lock_exam/" + current_exams_id,
type: "POST",
dataType: "json",
success: function (row) {
alert('success');
alert(row[0].access_status);
}
});
}
Мой teacher_internal_exam_management контроллер
public function lock_exam($current_exams_id)
{
$this->load->model('teacher_internal_exam_management_model');
$this->teacher_internal_exam_management_model->lock_exam($current_exams_id);
echo (json_encode($this->teacher_internal_exam_management_model->get_exam_details($current_exams_id)));
}
Мой teacher_internal_exam_management_model Модель
function lock_exam($current_exam_id, $data)
{
$this->db->query("update current_exams set access_status = 'locked' where current_exams_id='".$current_exam_id."'");
}
function get_exam_details($exam_id)
{
$query = $this->db->query("select * from current_exams
where
current_exams_id = '" . $exam_id . "'
");
return $query->result();
}
Теперь вызов ajax обновляет данные, но строка не возвращается эхом в контроллере. Предполагается, что функция успеха ajax не работает. Почему это не работает? Есть ли какие-либо проблемы в коде?
ваш URL является правильным относительно. – Ts8060
да ... я проверил его в первый раз и повторно проверил только сейчас .. да – user2557992
Это дает ошибку на вкладке «Сеть Chrome» или вкладке «Консоль». По-моему, проблема с URL-адресом. Где находится ваш Js. – Ts8060