[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.