Wednesday, April 25, 2012

how to bind ajaxStart/ajaxStop to a form?

How to bind ajaxStart/ajaxStop to a form?



I need a loading block to show while uploading the file



Now the form is not submitted at all



var iframe = $('<iframe name="iframe_file_upload" src="'+src_file_upload+'" style="display:none"></iframe>');
var btn_send = $('<input type="button" />')
.click(function(){
$('#form_upload_file').bind('ajaxStart', function(){
$(this).submit();
});
iframe.bind('ajaxStop', function(){
$(this).load(function(){
...


update



var btn_send = $('<input class="btn btn_margin_left" type="button" value="'+Lang.get('BTN_UPLOAD')+'" />')
.click(function(){
$('#form_upload_file').ajaxForm(function(response){
if(response.error){
// alert error
}
else{
// success
}




No comments:

Post a Comment