title: ajax upload multipart form data as json object
body: <p>Here there are form data with image. I need to send whole image data through json object. Below I have mentioned the code. under the below method I could get whole data except logo. I need to send whole data at once</p>
  
  <pre><code> &lt;form class="form-horizontal" id="companyData"&gt;
              &lt;fieldset&gt;
  
                  &lt;legend&gt;Add Company&lt;/legend&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="code"&gt;Code&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input id="code" name="code" type="text" placeholder="code" class="input-large"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="name"&gt;Name&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input id="name" name="name" type="text" placeholder="Name"  class="input-xlarge"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="logo"&gt;Logo&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input id="logo" name="logo" class="input-file" type="file"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="username"&gt;Admin Username&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input id="username" name="username" type="text" placeholder="" class="input-xlarge"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="AdminPassword"&gt;Admin Password&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;input id="AdminPassword" name="AdminPassword" type="text" placeholder="" class="input-xlarge"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="control-group"&gt;
                      &lt;label class="control-label" for="submit"&gt;&lt;/label&gt;
                      &lt;div class="controls"&gt;
                          &lt;button id="submit" name="submit" class="btn btn-primary"&gt;Save&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;/fieldset&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p><strong>here is my script</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("#submit").click(function (e) {
              e.preventDefault();
              var formData = JSON.parse(JSON.stringify(jQuery('#companyData').serializeArray()));
              $.ajax({
                  type: "POST",
                  url: "",
                  data: formData,
                  cache: false,
                  success: function (data) {
                  }
              });
  
          });
      });
  &lt;/script&gt;
  </code></pre>