Form表单POST方法总是返回406

上传格式限制:gif、jpg、jpeg、bmp、png

 form的提交如下两种,第一种iframe标签中是406页面,上传成功给的提示是上传失败。改用第二种,就能解决这个问题。

/*第一种提交方式:submit()*/
$('#uploadImg').submit();
//初始化时绑事件:
$('#div-uploadImg-dialog iframe').bind("load", function() {          
            
    if (this.contentWindow.document.body.innerHTML == "1") {
        uploadDialog.dialog('close');
        window.location.reload();
    } else {
        uploadDialog.dialog("close");
        commonConfirmDialog.init({
            'okHandler': function () {
                uploadDialog.dialog('open');
            }, 'cancelHandler': function () {
                 uploadDialog.dialog("close");
            }
        }).html('上传失败,是否需要重新上传?');
        commonConfirmDialog.show();
    }          		
});


/*第二种提交方式:ajaxSubmit()*/
$('#uploadImg').ajaxSubmit({
    success: function (responseText) {
        if (responseText == "1") {
            uploadDialog.dialog('close');
            window.location.reload();
        } else {
            uploadDialog.dialog("close");
            commonConfirmDialog.init({ 
                'okHandler': function () {
                    uploadDialog.dialog('open');
                },
                 'cancelHandler': function () {
                    uploadDialog.dialog("close");
                }
            }).html('上传失败,是否需要重新上传?');
            commonConfirmDialog.show();
        }
    }
});

 

你可能感兴趣的:(Form表单POST方法总是返回406)