首先下載 json plugin:
http://code.google.com/p/jquery-json/
get JSON:
var sysObj={};
//sysObj: {"Lans":"12","Contents":"1","modes":"1"}
$.getJSON("settings.json",function(data){
sysObj=data;
})
Sent JSON:
$("#system_btn").click(function(){
var encoded = $.toJSON(sysObj); // 把object encode 為 json
$.ajax({type:'POST',url:'tovalue.cgi',data:encoded,dataType:'json'}) // dataType:'json' 傳送資料為json
})
沒有留言:
張貼留言