Wednesday, October 1, 2008

[jQuery] Problem with JQuery Form, file upload and success option

Hi,

The code in my success option does not execute when I have a simple
form with a file field.

When I use a form without a form field, it works.

Here's the code

<form id="photo_upload_form" action="/upload" enctype="multipart/
form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<div>
<label>Choose your photo:</label>
<input type="file" name="photo" id="photo_filename" />
</div>

<p>Choose a .jpg, .png, or .gif file (1MB max file size)</p>
<p>
<span id="uploadbtn"><input type="submit" name="submit_upload"
value="Upload" /></span>
</p>

</form>

$(document).ready(function(){

$('#photo_upload_form').ajaxForm({
dataType: 'json',
beforeSubmit: function(){
alert('here'); // works
},
success: function(responseText){
alert('success'); // doesn't even go there
}
});

});

No comments: