javascript:
<script language="JavaScript" src="json.js"> </script>
$(document).ready(function(){
$("#lookfor_s").click(function(){
var y = $("#s_year").val(); //年
var m = $("#s_month").val(); //月
$.ajax({
type:"POST",
url:"test.php",
dataType:'json',
data:"year="+y+"&month="+m,
success:function(json){
$('#show_1').html(json[0]);
$('#show_2').html(json[2]);
} //success
}) //ajax
});
});
html:
<input type="button" name="lookfor_s" value="查詢" id="lookfor_s"/>
<span id="show_1"></span>
<span id="show_2"></span>
php:
require_once ('JSON.php');
$j = new Services_JSON();
$return_data = array();
$return_data[0] = iconv("big5","UTF-8","這是");
$return_data[1] = "test";
$jsonString = $j->encode($return_data);
echo $jsonString;
exit;
參考資料:
http://blog.xuite.net/vexed/tech/26580605
http://liaosankai.pixnet.net/blog/post/16753266
沒有留言:
張貼留言