部分代码:ajax:function changeCity(type,zhishi){

$.ajax({
            url: 'cc.php',
            type: 'post',
            data:   "act=ayzs&type="+type,
           success:  function(oj){
   //location.href="cj.php?act=award&wid="+wid+"&cid="+cid;
   //location.href="Olympic.php?act=ayzs&type="+type;
   openDiv(zhishi); //调用了一个js
 }});
}
html页面:
<{foreach from=$arr item=arr}>
         <div class="olKbodyCon1">
         <p><{$smarty.foreach.fd.iteration}>、<{$arr.OlyTopicContent}></p>
             <div class="olsel"><input type="radio" name="xuan" />&nbsp;&nbsp;A.<{$arr.OlyTopicAnswerA}>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="xuan" />&nbsp;&nbsp;B.<{$arr.OlyTopicAnswerB}></div>
            </div>
            <{/foreach}>
php页面:$type=isset($_REQUEST['type']); //随机选择20道题
$arr1=create_rand($phone,$type); //用了一个自定义函数从数据库读出 显示为数组
$smarty->assign("arr",$arr1);

解决方案 »

  1.   


    我用ajax刷新了一块页面,在。php页面读取数据库得到一个数组,我怎么传到html页面呢?
      

  2.   

    把AJAX返回值alert出来看看是啥,如果返回的是数组就json_encode,如果返回的是页面就直接塞到你要摆的地方   
      

  3.   

    我是用jquery 的ajax.ajax发送请求后,把返回的内容只用用 $('#id').empty(). $('#id').html(content);
      

  4.   

    把type  ajax传php  php处理获得数据  return 这个数据   
    success:  function(oj){
      $(".xx").html(data);
    }
      

  5.   


    success:  function(oj){
      $(".xx").html(oj);
    }
      

  6.   

    $arr1=create_rand($phone,$type);    //用了一个自定义函数从数据库读出 显示为数组
    exit(json_encode($arr1));
    query的ajax的type那块编程json就可以直接调用oj了