Passing key-value pair jquery array into .NET MVC action
<p>I have an jquery key-value pair array as following:</p>

<ul>
<li>The array is filled when check-boxes are checked </li>
<li>If a checkbox is unchecked, item will be removed from there</li>
</ul>

<p>The code for that part is:</p>

<pre><code>  $(document).on('click', '.chkItem', function () {
            if ($(this).is(':checked')) {
                product_ids[$(this).attr('id')] = "Checked";
            } else {
                delete product_ids[$(this).attr('id')];
            }
        });
</code></pre>

<p>This works fine, let's head onto the next part. Now I'm trying to send all these ID's from my view into a controller "Analyze" and action "Index", which looks as following:</p>

<pre><code>  $(".btnAnalyze").click(function () {
            if (jQuery.isEmptyObject(product_ids) == true) {
                alert("Array is empty");
            }
            else {

                var postData = { values: product_ids };

                $.ajax({
                    type: "POST",
                    url: "/Analyze/Index",
                    data: postData,
                    success: function (data) {
                        alert(data.Result);
                    },
                    dataType: "json",
                    traditional: true
                });

            }
        });
</code></pre>

<p>And my action looks like following:</p>

<pre><code> public ActionResult Index(List&lt;string&gt; values)
        {
            string id2= "";
            foreach (var id in values)
            {
                id2= id;
            }
// I'm trying to fetch the ID values here that I added into the array, but I'm not sure how... 

}
</code></pre>

<p>With this current method the contents of List values is </p>

<pre><code>"[object Object]" 
</code></pre>

<p>which is not what I want.. I need all of the ID's sorted out nicely into the list as I send them to the Action Index...</p>

<p>Can someone help me out with this???</p>