에서 자바 스크립트 코드를 작성내 index.php를 PHP
내 calendar_view.phpswitch ($action){
case "calendar":
echo "<script language=\"javascript\">\n";
echo "document.write('Hello World!')";
echo "</script>";
include($_STR_TEMPLATEPATH."/calendar_view.php");
break;
}
: 나는 index
에서 action
calendar
를 호출하고 calendar div
에 calendar_view.php
에 결과를 표시한다 아약스 기능이
<script>
function calendarList()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
document.getElementById("calendar").innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("GET","?action=calendar",true);
xmlHttp.send(null);
}
</scritp>
캘린더 사업부 :
<div id="calendar"></div>
calendarList function
을 호출 할 때 사례를 호출했지만 calendar div
에 결과를 표시하지 않았습니다.
도움이됩니다. 감사합니다
잘못하고 있습니다. http://stackoverflow.com/questions/11658596/is-echoing-javascript-code-condtionally-based-on-server-side-logic-considered-ha/11658717 –