Note that there are some explanatory texts on larger screens.

plurals
  1. POError handler isn't called when file is uploaded via Ajax using jQuery form plug-in
    primarykey
    data
    text
    <p>Here's my test case. If the form is posted, a 500 error response is sent. If not, the form is sent.</p> <p>If the file input tag is commented out, the error handler is called. If the file input tag is present, the error handler isn't called. I think this might have something to do with the fact that jQuery needs to use an iframe to handle the upload and iframes <a href="http://api.jquery.com/error/#comment-34139831" rel="nofollow noreferrer">don't seem to respond to the error handler</a>.</p> <p>Edit: If I add <code>iframe: true</code> to the options passed to <code>ajaxSubmit</code> to force the use of an iframe, the non-file-upload case stops working also, so it definitely has to do with the iframe.</p> <p>Edit2: I'm using the <a href="http://jquery.malsup.com/form/" rel="nofollow noreferrer">jQuery Form Plugin</a>.</p> <pre><code>&lt;?php if($_SERVER['REQUEST_METHOD'] == 'POST') { header('HTTP/1.1 500 Internal Server Error'); die; } else {?&gt; &lt;html&gt;&lt;head&gt; &lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=2.9.2'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='http://github.com/malsup/form/raw/master/jquery.form.js?v2.43'&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; jQuery(document).ready(function() { jQuery('a').click(function() {jQuery('form').ajaxSubmit({error: function(){alert('error handler called');}})}); }); &lt;/script&gt; &lt;/head&gt;&lt;body&gt; &lt;form method="POST"&gt; &lt;input type="text" name="mytext" /&gt; &lt;input type="file" name="myfile" /&gt;&lt;!-- comment this element out --&gt; &lt;input type="hidden" name="blah" value="blah" /&gt; &lt;a&gt;submit&lt;/a&gt; &lt;/form&gt; &lt;/body&gt;&lt;/html&gt; &lt;?php } </code></pre> <p>Is there any way to get the error handler to be called in both situations?</p>
    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.
    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