Wednesday, January 23, 2013

Json communication from php to jquery


-------------------------------------------------------------------------
Jquery code: 

$.post(url",{'product[]':b,store_id:slave_stores[d]}, function (data){

                  var response = $.parseJSON(data);

                  if(typeof(response.count) != 'undefined') {

                               alert( response.count);
                   }

});
-----------------------------------------------------------------------
Php Code in ajax function:

$reply = array(

                    'count' => $pcount,

                      'message' => "testing"

);

echo json_encode($reply);