Note that there are some explanatory texts on larger screens.

plurals
  1. POResource interpreted as Document but transferred with MIME type application/json warning in Chrome Developer Tools
    primarykey
    data
    text
    <p>I have the following snippet, which uses the jQuery Form plugin to post a form to the server (in ajax). </p> <pre><code> var options = { dataType: "json", success: function(data) { alert("success"); } }; $form.ajaxSubmit(options); </code></pre> <p>The form:</p> <pre><code>&lt;form enctype="multipart/form-data" id="name_change_form" method="post" action="/my_account/"&gt; &lt;div style='display:none'&gt;&lt;input type='hidden' name='csrfmiddlewaretoken' value='6c9b552aaba88b8442077e2957e69303' /&gt;&lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="id_first_name"&gt;First name&lt;/label&gt;: &lt;/td&gt; &lt;td&gt; &lt;input name="first_name" value="Patrick" maxlength="30" type="text" id="id_first_name" size="30" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="id_last_name"&gt;Last name&lt;/label&gt;: &lt;/td&gt; &lt;td&gt; &lt;input name="last_name" value="Sung" maxlength="30" type="text" id="id_last_name" size="30" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="hidden" name="form_id" value="name_change_form" /&gt; &lt;/form&gt; </code></pre> <p>The ajax implementation is working fine. But I am getting a warning</p> <blockquote> <p>Resource interpreted as Document but transferred with MIME type application/json</p> </blockquote> <p>in Chrome Developer Tools. I want to find out why the warning, or even better, a way to resolve it.</p> <p>I changed to use <code>$.post</code> instead and magically the error was gone since then. I have no idea why <code>$.post</code> works but not <code>$form.ajaxSubmit</code>. If someone can offer their explanation that would be great. At the very least, this problem is resolved. Below is the new code.</p> <pre><code>var url = $form.attr("action"); $.post( url, $form.serialize(), function(data) { alert("success"); }, "json" ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload