我有以下代码块,它使用jQuery将id为searchBox
的文本输入的内容发送到服务器.
$(document).ready(function () {
$('#searchBox').on('input', function () {
var searchContent = $(this).val()
if (searchContent.length == 0) {
// other not relevant code
}
else {
$.post('/checkAvailability',
{ domainName: searchContent },
function (data, status, jqXHR) {
console.log(status + ' ' + data);
});
}
});
});
如果搜索内容在3秒内没有更改,我如何才能调用$.post
函数?