title: Assign an object to 'data' property in '$.ajax' method of jquery
body: <p>This is what I know on the subject:</p>
  
  <p>We have an ajax function to which we can pass an object with properties like this:</p>
  
  <pre><code>    var ajaxRequest = {};
  
      ajaxRequest['type'] = 'POST';
      ajaxRequest['async'] = false;
      ajaxRequest['datatype'] = 'json';
      ajaxRequest['url'] = '/Query/getMydata';
  
      $.ajax(ajaxRequest);
  </code></pre>
  
  <p>one of these properties is the data parameter which is made of key / value pairs:</p>
  
  <pre><code>    ajaxRequest['data'] = {color: 'red' , name: 'Steve' }
  </code></pre>
  
  <p>I tried to do something like this:</p>
  
  <pre><code>    var oData = [];
      oData['color'] = 'yellow';
      oData['name'] = 'Fred';
  
      ajaxRequest['data'] = oData;
  </code></pre>
  
  <p>but it does not work.</p>
  
  <p>So my question is: there is an object that I can assign to the  'data' parameter, or I am forced to build the string with concatenation?</p>
  
  <p>EDIT==============</p>
  
  <p>Maybe I did not explain, I know that the method can be created by code like this:</p>
  
  <pre><code>     var ajaxRequest = {
        type: 'POST',
        async: false
        ....
        };
  </code></pre>
  
  <p>but I'm using objects and properties because I need to make the method 'generic', then I will add the 'if' like this:</p>
  
  <pre><code>    function ajaxReq(data){
           var ajaxRequest = {};
  
           if( !data.isEmpty()){
               ajaxRequest['data'] = data;
           }
  
             ajaxRequest['type'] = 'POST';
             ajaxRequest['async'] = false;
             ajaxRequest['datatype'] = 'json';
             ajaxRequest['url'] = '/Query/getMydata';
  
             ...
  
             $.ajax(ajaxRequest);
      }
  </code></pre>