如何从codeigniter控制器传递多个json变量来查看ajax。

I want to pass two variable of json to ajax from controller here I have little code of it.

echo json_encode($qry1);
echo json_encode($qry2);

How can I get this both in ajax and How can I use it like data.qry1 and data.qry2.

    $.ajax({
        url:"<?php echo base_url(); ?>getdata",
        type: "POST",           
        dataType: 'json',
        data:{Paper_name : p_name},

        success : function(data){                   


            if(data != ""){                 
              alert(data.qry1);

            }else{                                  

             alert(data.qry2);
       },
       error : function(data){

        alert(data.qry2);
       }
    });

Merge both independent array to one single array

$dataArray = array(
    'qry1' => $qry1,
    'qry2' => $qry1
);

echo json_encode($dataArray);

In ajax, add console.log(data) and check how its comming

Put the two variables into an associative array:

$qry = array(
    'qry1' => $qry1,
    'qry2' => $qry2
);

echo json_encode($qry);