範例程式 jQuery /JSON / PHP /json_encode / json_decode sample code

jQuery : 請參考這篇 : http://jsgears.com/thread-63-1-1.html

Microsoft 也提供 video 教學: http://msdn.microsoft.com/zh-tw/asp.net/dd310332.aspx#jQuery

$(document).ready( function(){
  var data = new Object();
  data.hello = "Hello";
  data.world = 'World';
  data.worked = " it worked ";
  data.somebool = true;
  data.array = new Array("he\"ll\"o", '"World"');
  var dataString = $.toJSON(data);
  $.post('phpfile.php', {data: dataString}, function(res){
      var obj = $.evalJSON(res);
      if(obj.somebool === true)
      $("#result").html(obj.hello + ' ' + obj.array[1] + obj.worked + ". Message from PHP: "+obj.php_message);
    });
});

… 未完