2010-12-11 127 views

回答

7

只需将您的数据作为对象和jQuery将通过$.param()序列化内部,例如:

$.ajax({ 
    //options.. 
    data: { key: "myValue" } 
}); 
//the same goes for shorthand methods: 
$.post("url", { key: "myValue" }); 

所有神奇的是基本的JavaScript虽然,$.param()只是使用encodeURIComponent()下做序列化(包括&编码)创建字符串时。

如果您发送的整个<form>只使用.serialize()其序列化整个<form>(所有成功的表单元素)的字符串 - 像一个正常的非Ajax提交会,例如:

$.post("url", $("form").serialize());