How to submit multipart formdata using jquery
<pre><code>&lt;form id="uploadForm" enctype="multipart/form-data" action="http://localhost:1337/ad/upload" method="post" name="uploadForm" novalidate&gt;
    &lt;input type="file" name="userPhoto" id="userPhoto" /&gt;
    &lt;input type="submit" value="submit" id="uploadImage" /&gt;
&lt;/form&gt;
</code></pre>

<p>This is my html form which accepts an image as file inout, the user can select an image file and then click submit. This works but the url of the current page changes to localhost:1337/ad/upload. I want the page to stay at the same url.</p>

<pre><code>$("form#uploadForm").submit(function(event) {
    event.preventDefault();
    var formData = new FormData($(this)[0]);
    var posting = $.post(url, formData);

})
</code></pre>

<p>I have tried this to send the form using jquery but i get an error : Uncaught Type error : Illegal Invocation</p>

<p>What data does the form submit when the type is multipart /formdata and how can we get this data on jQuery</p>