我正在尝试基于下拉选择来过滤记录,但是当我选择任何值时它都无法正常工作,请在下面的代码段中查找
控制器代码:
if (req.body.selectedName !== "All" && req.body.selectedName) {
findCriteria["status"] = req.body.selectedName;
}
js代码:
$("#listGoalTable").on("xhr.dt", function(e, s, json) {});
var list_goal_table = $("#listGoalTable").DataTable({
serverSide: true,
processing: true,
ajax: {
url: "/goal/reportgoalJson",
type: "POST",
data: function(d) {
console.log($("#seletionOption").val());
d.condition = "Opened";
d.selectedName = $("#seletionOption").val();
d.selectedValue = $("#seletionOption").attr("data-val");
}
},
$(document).on("change", "#newOneStatus", () => {
const name = $("#newOneStatus").attr("name");
const value = $("#newOneStatus").val();
const value = $("#newMentor").val();
$("#seletionOption").val(name);
$("#seletionOption").attr("data-val", value);
list_goal_table.ajax.reload();
});
$(document).on("change", "#newMentor", () => {
const name = $("#newMentor").attr("name");
const value = $("#newMentor").val();
$("#seletionOption").val(name);
$("#seletionOption").attr("data-val", value);
list_goal_table.ajax.reload();
});
HTML代码:
<div class="form-group col-md-2">
<label for="academicYear" class="control-label">
<strong>Status</strong>
</label>
<select class="form-control changeDropDown-0" name="status" id="newOneStatus">
<option value="All">All</option>
<option value="In_progress">In progress</option>
<option value="Applied_completion">Applied for completion</option>
<option value="Completed">Completed</option>
</select>
</div>
请检查为什么它不能正常工作?