I’m stumped on this. I’m trying to send an AJAX call by iterating over all the inputs and collecting their val() which is a string.
So that my params would hopefully look like this:
"action"=>"create",
"type"=>"zip",
"value"=> ["12", "13", "14", "14", "15", "16"],
"controller"=>"admin/distributions",
"email_id"=>"3"}
This is what I have, but its giving me an [Object object] as a value :
$(".all_of_morris").live("click", function(){
id = window.location.href.split("/")[5]
$.ajax({
type: "POST",
url: "/admin/emails/" + id + "/distributions",
dataType: "script",
data: { $.each($(".morris input"), function(){
value: $(this).val();
}),
type: "zip" }
});
});
If you need an array for the value property, you can use the jquery map function: