Wednesday, October 1, 2008

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

My mistake. I was doing something wrong in the back end code and since
I couldn't see the response, I thought it was the success option.

On Oct 1, 11:31 am, kojilab <koji...@gmail.com> wrote:
> 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: