Sending post data and file data in the same ajax request

Sending post data and file data in the same ajax request

Hello, everyone! I'm currently experiencing a problem where I don't know how to send text data via post and files.
Here is my code:
  1.  $(".form").submit(function(e) {
  2.       e.preventDefault(); // avoid to execute the actual submit of the form.
  3.       var url = $(this).attr("action"); // the script where you handle the form input.
  4.       $.ajax({
  5.              type: "POST",
  6.              url: url,
  7.              data: $("#form").serialize(), // serializes the form's elements.
  8.              success: function(data)
  9.              {
  10.                 // var obj = jQuery.parseJSON( data );
  11.                  alert(data); // show response from the php script.
  12.              }
  13.       });
  14.   });
And, here my HTML code:
  1. <form class="form" id="form" action="http://localhost:8888/api/addPost.php" method="POST">
  2.     <div class="list">
  3.  <label class="item item-input">
  4.    <input type="text" placeholder="Title" class="AddPosttitle" name="title">
  5.  </label>
  6.  <label class="item item-input">
  7.    <input class="description" type="text" placeholder="Simple Description (max 60 caracters)" maxlength="60" name="description">
  8.  </label>
  9.  <label class="item item-input">
  10.    <div>
  11.     <span id='button_upload'>Image : </span>
  12.    <input type='file' class="img" name="img">
  13. </div>
  14.  </label>
  15.  <label class="item item-input">
  16.    <textarea placeholder="Full description" class="full" name="full"></textarea>
  17.  </label>
  18.   <div class="padding">
  19.  <button class="button button-block button-positive submit-btn" type="submit">
  20.       Submit
  21.    </button>
  22.     </div>
  23. </div>
  24. </form>
Basicaly, it returns me the text, but not the file, and I don't want to do 2 ajax requests