关于数据库传入显示页面问题

#1 transcend

----------------------------------------------------------------------------
class main extends spController
{
function index(){
  $production=spClass("production");
  $id= $this->spArgs('p_id');     //这个是从AJAX传过来的
  $conditions= array('id'=>id);
  $this->cd =$production->findAll($conditions);      //怎么把点击事件完以后把这个查询结果传到显示页面中?
  $this->nd=$production->findSql("select * from production");
  $this->display("home/index.html");
}
-------------------------------------------------------------------------------
var ss =function doLog(str){
   var friendid =str
  function initXMLHttpRequest3(){
  if(window.XMLHttpRequest){ //Mozilla浏览器
   http_request=new XMLHttpRequest();
   if(http_request.overrideMineType){ //防止某些版本的Mozilla浏览器处理没有Mine Type信息的;内容出错
    http_request.overrideMineType("text/xml");
   }
  }else if(window.ActiveXObject){  //IE浏览器
   try{ //IE6或更高版本
    http_request=new ActiveXObject("Msxml2.XMLHTTP");
   }catch(s){ //IE5.x
    http_request=new ActiveXObject("Microsoft.XMLHTTP");
   }
  }
}
function check3(friendid,opendate){ //初始化XMLHttpRequest
  initXMLHttpRequest3(); //设置回调函数
  http_request.open("GET","index.php?c=main&a=index&p_id="+friendid,true);  
  http_request.onreadystatechange=callBack3; //使用AJAX引擎的核心对象发送请求
  http_request.send(null);
   
  function callBack3(){ //AJAX引擎在服务器端成功返回后自动调用该函数 //负责将服务器端返回的数据显示在客户的UI上
   if(http_request.readyState==4){ //服务器端已经处理完成
    if(http_request.status==200){  //服务器端处理成功
     document.getElementById("logarea").innerHTML="<{foreach from=$cd item=id}>"+   //在这里显示到页面是空的
''+
    "<{$id.id}>"+
    "<{$id.date}>"+
    "<{$id.unitname}>"+
    "<{$id.totalvalue}>"+
    "<{$id.addvalue}>"+
    "<{$id.mainproducts}>"+
    ""+
     ""+
""+
"<{/foreach}>";
    }
   }
    }
}
----------------------------------------------------------------------

2012-06-09 17:45:04

#2 transcend

在没有刷新的情况下传到显示页面。

2012-06-09 17:53:15

#3 jake

看手册
http://www.speedphp.com/interaction-ajax.html

{:soso_e160:}(不看手册就提问计算1)

2012-06-10 20:54:13

#4 transcend

jake 发表于 2012-6-10 20:54
看手册
http://www.speedphp.com/interaction-ajax.html
http_request.open("GET","index.php?c=main&a=index&p_id="+friendid,true);  
不知道为什么我这一句传不过去值,我以前用可以啊,在这里就不可以了。
我用手册的方法也是值传不过去。
--------------------------------------------------------
在控制器抛出结果来看,是空的。
--------------------------------------------------------

2012-06-11 19:39:57

#5 transcend

transcend 发表于 2012-6-11 19:39
http_request.open("GET","index.php?c=main&a=index&p_id="+friendid,true);  
不知道为什么我这一句传 ...
main.php  控制器代码
-------------------------------------------------------
function index(){
  $production=spClass("production");
  $id= $this->spArgs('p_id');
  $conditions= array('id'=>$id);
  $this->cd =$production->findAll($conditions);
  $this->display("home/index.html");
}
-----------------------------------------------------

2012-06-11 19:43:17

#6 jake

手册不是这样写的,请看手册,按手册的方法写,谢谢。

如果不按照手册的写法,那请自行Google

2012-06-11 20:27:05