php - JSON output in smarty template -


i have php file outputs json object . wanted display set of records of outputs display in smarty template . when echo json object , is showing like

[{"fname":"kashmiri","lname":"medhi"},{"fname":"kangkan","lname":"hazarika"},{"fname":"ikram","lname":"hussain"}]  

in outside template . using jquery getjson() function . php file :

foreach($res $a=>$v)             {                 $arr['fname'] = $v->um_first_name;                 $arr['lname'] = $v->um_last_name;                 $data[] = $arr;             }             $json_obj = json_encode($data);             echo $json_obj; 

the js file :

$('document').ready(function() {     $.getjson('http://localhost/basic_framework/index.php ?menu=search_22',callback);  }); function callback(data) {     $.each(data,function(i,fi)     {            var info ='';                info+=dte.lc;         info+='<div id="ids">'+fi.fname[0]+'</div>';         info+='<div id="nws">'+fi.lname[0]+'</div>';          $(info).appendto("#friend_info");     }); }    

where doing wrong ?

if understood right, should use return instead of echo. because echo in thread , won't make callback() function work.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -