My index.php
switch ($action){
case "calendar":
echo "<script language=\"javascript\">\n";
echo "document.write('Hello World!')";
echo "</script>";
include($_STR_TEMPLATEPATH."/calendar_view.php");
break;
}
my calendar_view.php:
I have an ajax function which should call the action calendar from the index and display the result on calendar_view.php in calendar div
<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>
The calendar div:
<div id="calendar"></div>
When I call the calendarList function it did call the case, but did not display the result in calendar div.
Any help. Thanks
There is not much to display there. If everything works like you described, the response is appended to the DOM, but the JavaScript-alert will never be executed.
Try
alert(xmlHttp.responseText);to be absolutely sure that your response is correct. If it is, you can go from there.