js部分:
function onck(xyz){
confia("__URL__/getCode_group/cond/"+xyz);
}
//ajax发出请求
function confia(actionurl){
    jQuery.ajax({
        url: actionurl,//提交访问的URL
        type: 'POST',//提交的方法
        dataType: 'html',//返回的内容的类型,由于PHP文件是直接echo的,那么这里就是text
        timeout: 1000,//超时时间
        error: function(){ //如果出错,执行函数
        },
        success: function(data)
        {
            resu(data,"1");
        }
    });
}//ajax返回数据
function resu(data,status)
{
alert(data);//在这里怎么获取不到ajax返回的数据?????

}php后台代码:
function getCode_group(){
$db     =   Db::getInstance();
$cond=$_REQUEST['cond'];
$str="select * from info_codedtl where code_no='".$cond."' AND code_type='AST18'";
$listr=$db->query($str);
echo json_encode($listr);
}

解决方案 »

  1.   

    你直接在success那个函数里面加上eval('msg='+ data +';');然后alert(msg)试一下,放到外面是不可以获得的,具体原因我也没找到过.
      

  2.   

    经测试 Jquery ajax部分代码没问题问题出在后台部分echo json_encode($listr); 看看能正常输出吗?
      

  3.   

    $listr=$db->query($str);//这一步里你有fetch_array吗???
    echo json_encode($listr);
      

  4.   

    看了一下 可能是你的php没有正确返回值,检查一下php输出吧