日期:2014-05-16  浏览次数:20631 次

请问如何php如何返回变量+组装html给ajax
function html($select,$name){
global $pagecon;
$a='1';
$b='2';
$result='';
$result.='<ul id="thumbs">';
while($row=$select->fetch()){
$result.='<li class="'.$name.'isotope-item">';
$result.='<img src="ztImg/'.$row['riseimg'].'"width=235 height=300 alt=""//></div><ul>';
$result.='<h3 class="title">'.$row['ztname'].'</h3>';
$result.='<span class="category">'. $row['zttype'].'</span>';
$result.='<p class="intro">推荐日期:'.$row['zttime'].'</p></div></li>';
}
$result.='</ul>';
$result.='<center><h4>'.$pagecon.'</h4></center>';
return $result,$a,$b;
}

需要返回$a变量和$b变量以及一个组装好的$result的html给ajax  请问在不用json的情况下 如果封装给ajax

------解决方案--------------------
return "$result,$a,$b";

success:function(json){
            a = json.split(',');

------解决方案--------------------
function html($select,$name){
global $pagecon;
$a='1';
$b='2';
$result='';
$result.='<ul id="thumbs">';
while($row=$select->fetch()){
$result.='<li class="'.$name.'isotope-item">';
$result.='<img src="ztImg/'.$row['riseimg'].'"width=235 height=300 alt=""//></div><ul>';
$result.='<h3 class="title">'.$row['ztname'].'</h3>';
$result.='<span class="category">'. $row['zttype'].'</span>';    
$result.='<p class="intro">推荐日期:'.$row['zttime'].'</p></div></li>';
    }
$result.='</ul>';
$result.='<center><h4>'.$pagecon.'</h4></center>';
return $result.'--'.$a.'--'.$b;//用--来连接返回
}


function getData(page){
        alert('ok');
     $.ajax({
     type:'post',
     url:'action/test.php',
    data: {'pageNum':page-1},
        beforeSend:function(){
            $("#sss ul").append("<li id='loading'>loading...</li>");
        },
        success:function(json){
            var arr=json.split('--');