views:

174

answers:

1

I have an array (for checkboxes) that I need to pass alongside the regular form in an ajax post, but can't seem to get this to work:

new_data = [a,b,c,d,e];

somedata_assoc = JQuery.param({'choices[]': new_data});

    $.ajax({
        type: "POST",
     url: contract_qurl,
     data: $(div).find("form").serialize()+"&"+somedata_assoc,
     context: $(this),
     success: function(data) { $("#results_table").html(data); }
    });
+1  A: 

I'm getting a javascript error on this line

new_data = [a,b,c,d,e];

I had to change it to this

new_data = ['a','b','c','d','e']; 

you capitalized the J in jQuery in this line

somedata_assoc = JQuery.param({'choices[]': new_data});

should be this (or just the $ shorthand)

somedata_assoc = jQuery.param({'choices': new_data});

also, i dont think you need the brackets, in most cases they would make it more difficult to retrieve the data on the server

Yisroel
Thanks for so much for looking over this... I didn't realize the 'J' had to be lowercase! Also, you're right about the brackets. Everything posts fine now!
Dan