我已经使用的其他3页的日期选择器功能,所有的伟大工程中,但现在我想将它添加到一个基于Ajax的函数调用showbookings制作了网页。目前有8个点击功能在加载动态内容后正在重新附加,但我无法让datepicker工作,显示,没有任何内容。那么,你如何采取$(文件)。就绪(函数,并将其放入Ajax调用?我有我的输入级=“DATEPICKER1”如何放置文档准备功能的AJAX功能
function showbookings(str, pass) {
if (str === "") {
document.getElementById("txtBookings").innerHTML = "";
return;
}
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtBookings").innerHTML = xmlhttp.responseText;
*********
}
};
xmlhttp.open("GET", "page1.php?q=" + str, true);
xmlhttp.send();
}
$(document).ready(function() {
$(".datepicker1").datepicker({
showOn: 'both',
buttonImage: 'images/calendar.gif',
buttonText: 'Pick Date',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
showAnim: 'slideDown',
duration: 'fast',
onClose: function (text, inst) {
$(this).focus();
}
});
});
您已经标记了这个'jQuery',所以**使用jQuery **。停止手动滚动您的AJAX请求,并使用['$ .get'](http://api.jquery.com/jQuery.get/)。您绝不会像jQuery的AJAX方法那样生成稳健,无缺陷和跨平台的东西,所以只需使用jQuery为您提供的东西。你的整个'showbookings'方法应该用'$ .get(“page1.php?q =”+ str)'替换。 – meagar
此外,[请停止在您的帖子和评论中使用签名](http://stackoverflow.com/faq#signatures)。我指的是“谢谢,库尔特”。您的帖子已经使用您的用户名登录。 – meagar