您的代码应该是这样的
function showCustomer(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("divtoDisplayInfo").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("divtoDisplayInfo").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/yoursite/controllername/action/str,true); //if you use redirect and windows environment
xmlhttp.send();
}
你应该预料到行动的看法等做了正常的蛋糕加工,在控制器中获取数据,渲染视图,如果有错误设置的操作autorender假。
但我只是建议你下载的Jquery添加到您的CakePHP框架这种简单的线条
$("divToDisplayInfo's_ID").load("Controllername/action")
解决您的问题。
你可以使用ajax。 – Vishal 2012-08-17 06:10:27
你知道吗javascript或jquery? – 2012-08-19 01:21:28
有人可以给我一个例子,我搜索了4个小时,什么都没有... – user1606032 2012-08-19 01:45:00