袁来如此的工作笔记
袁来如此的工作笔记
竹杖芒鞋轻胜马,谁怕? 一蓑烟雨任平生。

ajaxSubmit使用讲解

浏览量:630

 
$("#myupload").ajaxSubmit({
dataType:  'json',
url:"php/action.php?act=register",
beforeSend: function() {
        showimg.empty();
        progress.show();
        var percentVal = '0%';
        bar.width(percentVal);
        percent.html(percentVal);
        btn.html("上传中...");
    },
uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        bar.width(percentVal);
        percent.html(percentVal);
    },
success: function(data) {
        files.html("<b>"+data.name+"("+data.size+"k)</b> <span class='delimg_REG' rel='"+data.pic+"'>删除</span>");
        var img = "/weibo2/php/files/headpictures/"+data.pic;
        showimg.html("<img src='"+img+"'>");
        btn.html("上传头像");
},
error:function(xhr){
        btn.html("上传失败");
        bar.width('0')
        files.html(xhr.responseText);
}
});


ajaxForm不能提交表单。在document的ready函数中,使用ajaxForm来为AJAX提交表单进行准备。提交动作必须由submit开始 

ajaxSubmit 马上由AJAX来提交表单。你可以在任何情况下进行该项提交。 


打赏