1

Given this form

<form id="posts_form">
    <input type="file" value="" name="picture" >

    <span class="picture_js fc-button fc-button-prev fc-state-default fc-corner-left fc-corner-right">
        <span class="fc-button-inner">
            <span class="fc-button-content save_button">Share</span>
            <span class="fc-button-effect">
                <span></span>
            </span>
        </span>
    </span>
</form>

I'm using this <span> based button for style purposes.

What I'm trying to do is bind a click event on the <span> button and fire a submit function, like:

$('.picture_js').click(function(e){
    e.preventDefault();
    pictureUpload();
    return false;
});

function pictureUpload() {

        var options = { url: 'chat/upload' }

    $('#posts_form').ajaxForm(options);
}

But there is no response to clicking on the button (no errors on console either) -- any suggestions how to make this work?

2
  • I don't see any 'posts_form' element in your html, is this the whole of the html? Commented Jun 24, 2011 at 2:40
  • sorry @iforce2d - just corrected the code and added id to the form Commented Jun 24, 2011 at 2:51

1 Answer 1

1

I think you may need to include and implement both beforeSubmit and success options for file upload to work, as suggested in this post: Jquery form plugin file upload.

Try this:

function pictureUpload() {

    var options = { 
        url: 'chat/upload',
        success: function() {},
        beforeSubmit: function() {}
    }

    $('#posts_form').ajaxForm(options);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.