Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on your comment:</p> <p>"Thanks for that suggestion. $.ajax does not load the at all. It shows an error which you may know of. Although your suspicion is right because, when I use "this.ajax" the file does get uploaded but the console shows an error "Type has no method ajax"</p> <ul> <li>You can't upload files using <code>$.ajax()</code> the same way you usually upload your form data.</li> <li>Because of the error when you use <code>this.ajax</code> the form gets submitted. That's why you see the JSON response in the browser.</li> </ul> <p>The question is where does <code>this.ajax</code> come from? Did you copy the code from an example that uses a library you haven't included?</p> <p>In order to upload files via AJAX you need some kind of plugin (doing it yourself is some effort, especially if you need support for older browsers). </p> <h2>Update</h2> <p>The submit handler should be as follows:</p> <pre><code>form.submit(function (e) { e.preventDefault(); $(this).ajaxSubmit().done(function (data) { var x = JSON.parse(data); alert("Success : " + x); }).fail(function (data) { var x = JSON.parse(data); alert("Error : " + x); }); }); </code></pre> <p>Explanation: Since you want to call a jQuery plugin you need a jQuery object, hence <code>$(this)</code>. <code>ajaxSubmit()</code> does not need any arguments (you can pass in options if you want, though). Because I didn't pass in arguments the callbacks are appended, in this case with <code>done</code>and <code>fail</code> (instead of <code>success</code> and <code>error</code>). </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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