使用ajax从servlet获取数据时遇到问题。反应太慢了。有人建议如何更快地获取数据?以下是我的代码
function loaduedate(outlet,c) {
var d1 = new Date();
var d = new Date();
$.ajax({
url: 'GetDueDate',
type: 'post',
data: {out: outlet, opt: c},
dataType: 'json',
success: function(data) {
alert(JSON.stringify(data));
$("#txtduedateno").val(data.duedays);
var numdays = $('#txtduedateno').val();
d.setDate(d.getDate() + parseInt(numdays));
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
if (weekday[d.getDay()] === "Sunday") {
d.setDate(d.getDate() + 1);
}
}
});
}
function changeTextBoxForItem(Id1, Id2) {
$(Id1).on("keydown", function(e) {
if (e.keyCode == 112) {
e.preventDefault();
loaduedate(outletid,1);//loaduedate function calling from here
}
});
}