处理具有许多 AJAX 调用的 jQuery 语句的最佳方法是什么?
下面的代码似乎效率低下。
$("#search_building").on("change blur", function () {
var building = $("#search_building").val();
var room = $("#search_room").val();
var dept = $("#dept").val();
var dataString = 'room=' + room + '&' + 'building=' + building + '&' + 'dept=' + dept;
$.ajax({
type: "POST",
url: "process_building.php",
data: dataString,
cache: false,
success: function (html) {
$('#search_room').html(html);
}
});
$.ajax({
type: "POST",
url: "process_timetableMon.php",
data: dataString,
cache: false,
success: function (html) {
$('#grid2_mon').html(html);
}
});
$.ajax({
type: "POST",
url: "process_timetableTue.php",
data: dataString,
cache: false,
success: function (html) {
$('#grid2_tue').html(html);
}
});
$.ajax({
type: "POST",
url: "process_timetableWed.php",
data: dataString,
cache: false,
success: function (html) {
$('#grid2_wed').html(html);
}
});
$.ajax({
type: "POST",
url: "process_timetableThu.php",
data: dataString,
cache: false,
success: function (html) {
$('#grid2_thu').html(html);
}
});
$.ajax({
type: "POST",
url: "process_timetableFri.php",
data: dataString,
cache: false,
success: function (html) {
$('#grid2_fri').html(html);
}
});
});