Get JSON response from Form Submit
<p>I am not front end developer and I'm spending a quite time trying to do so. Hope you guys can help me.
I have a form which sends files to an API in server, like below:</p>

<pre><code>&lt;form id="uploadForm" action="url/upload/" method="post" enctype="multipart/form-data" accept-charset="ISO-8859-1"&gt;   

      &lt;div class="inputFileCustom"&gt;
        &lt;input type="file" size="45" name="file" id="uploadFiles" accept="application/pdf"/&gt;
        &lt;label for="uploadFiles"&gt;
            &lt;div class="ic-bt ic-bt-details ic-bt-text btn btn-border"&gt;
            Choose a file
            &lt;/div&gt;
        &lt;/label&gt;
    &lt;/div&gt;

    &lt;input type="submit" value="Upload PDF" class="btn btn-primary" /&gt;
&lt;/form&gt;
</code></pre>

<p><code>url/upload</code> returns a JSON, like:</p>

<pre><code>{ "status": "ok"/"fail" }
</code></pre>

<p>I need two things:</p>

<ol>
<li>Prevent submit to redirect to <code>url/upload</code>;</li>
<li>Get JSON response from server and, if successful, call <code>loadFiles()</code> function (which is already working).</li>
</ol>

<p>I'm using javascript for <code>loadFiles()</code> function, but its very simple.</p>