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);
}
});