Ajax表单不适用于IE

时间:2014-03-24 12:53:04

标签: jquery ajax internet-explorer

$(document).ready(function () {
    $('#upload_photo').click(function () {
        $('input[type=file]#upload_myphoto').click();
    });
});
$(document).ready(function () {
    $("input[type=file]#upload_myphoto").change(function () {
        $("#node_profilepic").prop('src', 'loader.gif');
        $("#upload_profilepic").submit();

    });
});
$(function () {
    $('#upload_profilepic').ajaxForm({

        beforeSubmit: ShowRequest,

        success: function (responseText, statusText) {
            alert(responseText);
            //$("#node_profilepic").prop('src',responseText);
            $('.iframe').click();
        },
        error: AjaxError
    });
});

function ShowRequest(formData, jqForm, options) {
    //alert(formData);
    var queryString = $.param(formData);
    // alert(queryString);
    return true;
}

function AjaxError() {}

此代码用于使用Ajax调用上传图像,它可以在除IE之外的所有浏览器上运行。请告诉我,我可以使用IE

调用Ajax表单

1 个答案:

答案 0 :(得分:0)

尝试将setTimeout()用于IE

$(function(){
    $('input[type=file]#upload_myphoto').change(function () {
        setTimeout(function(){
            $("#node_profilepic").prop('src', 'loader.gif');
            $("#upload_profilepic").submit();
        },100);// you can try 0 in place of 100
    });
});

阅读Inconsistent change event in IEJquery: change event to input file on IE