-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