title: Javascript Associative Array Becomes Empty On AJAX POST
body: <p>I am in a problem. I have a page with several <code>text</code> field with same class name and different <code>attribute values</code>. I would like to create an array which having <code>unique</code> key with joining the <code>text field</code> <code>attribute</code> values. And pass it to a <code>PHP</code> page using <code>ajax</code>. </p>
  
  <p>My problem is</p>
  
  <p><b>I can create the array successfully. But when I try to send the data through ajax, it become empty and the post array did not contain that value. But when I try to <code>console</code> the array, then it has the value </b></p>
  
  <p><b>My JQuery code is</b></p>
  
  <pre><code>$(document).on('click', '#mybutton', function () {
  
      var c_array = [];
      $('.class').each(function(){
  
          var val1 = $(this).attr('attr1');
          var val2 = $(this).attr('attr2');
          var val3 = $(this).attr('attr3');
          var key = val1+'_'+val2+'_'+val3;
          var no = $(this).val();
          c_array[key] = no;
          alert(c_array[key]);
      });
      console.log(c_array);
      var type = 'check_cookie';
      $.ajax({
          type: 'POST',
          url: 'action.php',
          dataType: 'json',
          async: false,
          data: { type: type, c_array: c_array },
          success: function (data) {
              console.log(data);
              if (data.msg !== '' &amp;&amp; data.msg !== null) {
                  window.location = 'new.php';
              }
              else {
                  alert('error');
              }
          }
      });
  });
  </code></pre>
  
  <p>What is the problem with this code? Please help me. Thank u all in advance....</p>