jquery mobile - ajax json output parsing in jquerymobile -


    public function actionajaxsearch()  {          $data_fetched=person::model()->findbyattributes  (array('code'=>'cust0001'));          echo cjson::encode($data_fetched); }      $('#searchresult').live('pageshow', function(e,info)     {      $.post('?r=mobile/ajaxsearch',$('form').serialize(),     function(res)     {             arrayvalue =res;             $.each(arrayvalue, function(i, profile) {       alert(i);       alert(profile);     });        }    }); 

i getting output json encode one. in traversing alert getting value each character not key or value. help?

adding datatype , contenttype solved problem. added complete code other's ref.

     public function actionajaxsearch()  {      $data_fetched=person::model()->findbyattributes  (array('code'=>'cust0001'));      echo cjson::encode($data_fetched); }          $('#searchresult').live('pageshow', function(e,info)        {           $.ajax({             beforesend: function() { $.mobile.showpageloadingmsg(); },              complete: function() { $.mobile.hidepageloadingmsg() },              url: '?r=mobile/ajaxsearch',             data: $('form').serialize(),             type: 'post',             contenttype: "application/json",             datatype: "json",             success:function(res) {                 if(res !='')                 {                 $.each(res, function(key, value) {                     var li='<li><a href="#">'+value['code']+'</a></li>';                      $("#mylist").append(li); //append li ul of id list                  }); //eachfunction                 $('#mylist').listview();                  $('#mylist').listview('refresh');         }//sucess       });    

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -