Kevin Thorpe wrote: > 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); > }); > > Oh. I'm an idiot!
I was creating an array, not an object. I didn't realise the subtle difference between the two. Changing postdata = [] to postdata = {} fixes it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery (English)" group. To post to this group, send email to jquery-en@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-en?hl=en -~----------~----~----~----~------~----~------~--~---