$("#summary").val(‘aaa‘); $("#title").val(‘bbb‘); $("#description").val(ck.description.getData()); $.post("....../save.json",$("#carrierForm").serializeArray(),function(result){ result = eval("("+result+")"); if(result.status == "true" || result.status == true){ alert(result.msg); } else { alert(result.msg); } });
传值为summary:aaa title:bbb
在spring mvc后台方法参数列表里面添加这2个参数即可获取,或者添加包含这2个参数的,并且进行过get set的bean
此为w3c例子
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ x=$("form").serializeArray(); $.each(x, function(i, field){ $("#results").append(field.name + ":" + field.value + " "); }); }); }); </script> </head> <body> <form action=""> First name: <input type="text" name="FirstName" value="Bill" /><br /> Last name: <input type="text" name="LastName" value="Gates" /><br /> </form> <button>序列化表单值</button> <div id="results"></div> </body> </html>
原文:http://www.cnblogs.com/cuiyf/p/3620906.html