-2
我通過ajax向控制器/函數發送post請求,並獲得成功的結果:它將結果加載到同一頁面,因爲它總是,但我想退出ajax時,我到達控制器/函數,因爲我想加載不同的視圖$ this-> load-> view('htmlfile')。如何停止類型後的ajax請求:發佈
function test() {
var wingId = $('#wing_id').val();
var classId = $('#class_id').val();
var sectionId = $('#section_id').val();
var gender = $('#gender').val();
$('#error').hide();
$.ajax({
url: "<?php echo base_url()?>admin/library/totalStudentsReportPrint/",
data: {
wingId: wingId,
classId: classId,
sectionId: sectionId,
gender: gender
},
type: "post",
success: function (result) {
$('#data_result').html(result);
}
});
}
PHP的控制器功能
function totalStudentsReportPrint(){
$student_data['wingId'] = $_POST['wingId'];
$student_data['classId'] = $_POST['classId'];
$student_data['sectionId'] = $_POST['sectionId'];
$student_data['gender'] = $_POST['gender'];
$this->load->view('institute/admin/library/total_students_btm_tbl_print',$student_data);
}
我不明白你的問題?你想加載其他模板?爲什麼不通過ajax發送模板路徑,並檢查函數中的$ _POST值? – kaito