I don't know what the answer is, Wichert, but I'm *very*
interested in finding out because I'm working on this very
problem right now.

>From what I read yesterday, a file can't be uploaded via AJAX
and an iFrame or some other solution has to be involved to
make it work.  So far, I haven't been able to get a demo
I found working.

Rick

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Wichert Akkerman
Sent: Friday, February 27, 2009 7:57 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] jquery.form fails to handle JSON responses with iframe
submit


I am running into what I think is a bug in jquery.form (version 2.21): I
have a little form with a single file input element it. What I want to do is
do an AJAX-submit on it as soon as the user selects a file, and handle the
JSON response to make some changes to the page. The markup is very simple:

         <form method="POST" enctype="multipart/form-data"
accept-charset="UTF-8" id="uploadForm"
               action="/cms/addImage">
           <fieldset class="concise">
             <label for="image.upload" id="imageUpload">Image
               <input type="file" name="image.upload"/>
             </label>
           </fieldset>
         </form>

And the AJAX logic looks like this:

     $("input[name=image.upload]").change(function() {
         $(this.form).addClass("processing")
                     .ajaxSubmit({cache: false,
                                  dataType: "json",
                                  success: function() {
                                      alert("done");
                                  },
                                  error: function() {
                                      alert("oops");
                                  }
                                  });
     });


The form is correctly submitted to the server, which sends the right JSON
response back. But I never get that result: instead the browsers pops up a
window telling me it does not know how to handle application/json and if I
want to save the response. This is not quite what I had in mind.

Is this a bug in jquery.form, or am I missing something?

Regards,
Wichert.


Reply via email to