カレンダー選択入力のあるhtmlページがあります。localhost で開くと正常に動作していますが、php ページで ajax を介して同じコードを呼び出していますが、動作していません。以下はHTMLコードです
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker({
numberOfMonths: 3,
showButtonPanel: true
});
});
</script>
</head>
<body>
<input type="text" id="datepicker" />
</body>
</html>
PHPページで上記のコードを呼び出し、そのページをajax経由でロードすると、上記のコードが機能しません。
私は2つのphpファイルdelete.php、deleteDateCalender.phpを使用しています
delete.php のコード
<html>
<head>
<title>test</title>
<script>
function deleteCalDateAjax()
{
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)
{
//alert(xmlhttp.responseText);
document.getElementById("calenderDIV").innerHTML=xmlhttp.responseText;
//alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","deleteDateCalender.php",true);
xmlhttp.send(null);
}
</script>
</head>
<body>
<form>
<input type="button" value="test" onclick="deleteCalDateAjax();" />
<div id="calenderDIV">
</div>
</form>
</body>
</html>
deleteDateCalender.php のコード
<input type="text" id="datepicker" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker({
numberOfMonths: 3,
showButtonPanel: true
});
});
</script>
delete.php のテスト ボタンをクリックすると、deleteDateCalender.php が呼び出されます。
上記のコードで何が間違っているか分かりますか?
どんな助けでも大歓迎です。