There are loads of questions and answers regarding the issue of posting arrays back to the server using jquery.
However I cant seem to find any solutiion to the problem I'm having. Basically the code below should return an array of ID's back to the server:
I know the array contains items as the length of the array always matches the number of selects that have the option "true" selected
var option = $(".option-select").filter(function () { return $(this).val() == "true"; }).map(function () { return this.id; }).get();
alert(option.length);
$.post("/Quote/GetOptionPrice", { myParam: option }, function (response) { $(".price").html(response); });
This is what is passed to the server:
"myParam[]"
Where am I going wrong?
var option = $('.option-select').filter(function () {
return $(this).val() == "true";
}).map(function () {
return this.id;
}).toArray();
$.ajax({
url: '/Quote/GetOptionPrice',
type: 'POST',
data: { myParam: option },
traditional: true,
success: function(response) {
$('.price').html(response);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With