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?
I think you may need to include and implement both
beforeSubmit
andsuccess
options for file upload to work, as suggested in this post: Jquery form plugin file upload.Try this: