我在config.php中有CSRF保护True。 单击标准/类名称后,ajax请求无效。
请帮帮我,谢谢。
查看代码:
<?php echo form_open('admin/Teacher/add_teacher_by_subject') ?>
<div class="form-group">
<label>Standard / Class Name<span class="text-danger">*</span></label>
<select class="form-control" name="standard_name" id="standard_name" style="width: 100%;">
<option value="">----Select Standard / Class----</option>
<?php foreach ($standard as $value): ?>
<option value="<?php echo $value['standard_id'] ?>"><?php echo $value['standard_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>Section<span class="text-danger">*</span></label>
<select class="form-control" name="section_name" id="section_name" style="width: 100%;">
</select>
</div>
<?php form_close() ?>
AJAX代码:
<script>
$(document).ready(function () {
$('#standard_name').change(function () {
var standard_id = $('#standard_name').val();
if (standard_id != "") {
var post_url = base_url + "admin/Teacher/get_section_name/" + standard_id;
// console.log(standard_id);
$.ajax({
type: "POST",
url: post_url,
success: function (result)
{
var obj = JSON.parse(result);
var options = "";
options = "<option value=''>----Select Section / Division----</option>";
for (x in obj) {
options += "<option value='" + obj[x].section_id + "'>" + obj[x].section_name + "</option>";
}
document.getElementById("section_name").innerHTML = options;
} //end success
}); //end AJAX
}
});
});
</script>