代码:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>使用$.param()进行数组元素序列化title> <script type="text/javascript" src="Jscript/jquery-1.4.2-vsdoc.js"> script> <script type="text/javascript" src="Jscript/jquery-1.4.2.js"> script> <style type="text/css"> body{font-size:13px} div{margin:5px;padding:10px;border:solid 1px #666; background-color:#eee;width:700px} style> <script type="text/javascript"> $(function() { var arrInfo = { id: 101, name: "tao", sex: 0 }; //基本信息数组 //分数和汇总信息数组 var arrScore = { Score: { chinese: 90, maths: 100, english: 98 }, SunNum: { Score: 288, Num: 3 } }; //序列化各数组 var arrNewInfo = $.param(arrInfo); var arrNewScore = $.param(arrScore); var arrDecScore = decodeURIComponent($.param(arrScore)); //显示序列化后的数组 var strTmp = "arrInfo数组序列化后:"; strTmp += arrNewInfo; strTmp += " arrScore数组序列化后:"; strTmp += arrNewScore; strTmp += " arrScore序列化解码后:"; strTmp += arrDecScore; //显示在页面中 $("#divTip").append(strTmp); }) script> head> <body> <div id="divTip">div> body> html>