param() 方法
Param()
序列化一個key/value對象,該序列化值可以進行AJAX請求時在URL查詢字串中使用,以下範例執行結果width=1680&height=1050
var params = { width:1900, height:1200 };
var str = jQuery.param(params);
$("#results").text(str);
語法
jQuery.param(object,traditional)
参数
描述
object
要進行序列化的數值或對象。
traditional
規定是否使用傳統的方式淺層進行序列化(参數序列化)。
範例
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
personObj=new Object();
personObj.firstname="Bill";
personObj.lastname="Gates";
personObj.age=60;
personObj.eyecolor="blue";
$("button").click(function(){
$("div").text($.param(personObj));
});
});
</script>
</head>
<body>
<button>序列化对象</button>S
</body>
</html>
Last updated
Was this helpful?