[jQuery] How do I build a variable array/object to use $.post?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, I'm struggling a bit to get $.post to work. I can get it working as
documented, ie.
$.post("url", { param1: 1, param2: 2 } );
but I want variable fields on my form (identified by the class
'edit_field') to be posted to the url
I thought the approach below would work, postdata is built correctly,
but it sends nothing.
What am I doing wrong?
thanks
var postdata = [];
// get all the edit fields
$.each($('.edit_field'),function() {
postdata[this.name] = $(this).val();
});
// and sent it away
$.post("/spt/newcanonical",
postdata,
function(data) {
alert(data);
});
<div class="moz-signature"><font color="#333333"
face="Helvetica, Arial, sans-serif" size="2">
</font>
</div>
</body>
</html>