title: Passing an array of objects to the controller using JSON
body: <p>My array is like this:</p>
  
  <pre><code>Array[2]
   0: Object
          StockNo: "1"
          InvoiceNo: "1234"
          MaterialName: "MaterialName1"
          PONo: "1234"
          PRNo: "2124"
          Project: "ProjectName"
          Qty: "1"
          Remarks: "Test"
          Supplier: "SupplierName"
          TotalAmount: "23"
          Type: "2"
          Unit: "23"
  
    1: Object 
          StockNo: "2"      
          InvoiceNo: "1234"
          MaterialName: "MaterialName2"
          PONo: "1234"
          PRNo: "2124"
          Project: "ProjectName2"
          Qty: "1"
          Remarks: "Test"
          Supplier: "SupplierName"
          TotalAmount: "23"
          Type: "2"
          Unit: "23"
  </code></pre>
  
  <p>and this 2 array is inside in variable named <strong>"inventoryList"</strong>
  and I want this to pass in my Controller. I used </p>
  
  <blockquote>
    <p>JSON.stringify(inventoryList)</p>
  </blockquote>
  
  <p>but it's not working.</p>
  
  <p>Here's my script:</p>
  
  <pre><code>function addSomething() {
      var dateReceived = $('#DateReceived').val();
      $.ajax({
          url: "/MyController/Create",
          type: 'post',
          dataType: 'json',
          async: false,
          data: {
              'dateReceived': dateReceived,
              'rrList': JSON.stringify(inventoryList)
          },
          success: function (data) {
              if (data.errorMessage != '') {
                  alert(data.errorMessage);
              }
              else {
                  window.location.href = '/MyController/Index';
              }
          }
      })
  }
  </code></pre>