2014-03-24 59 views
0
$(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以外的所有浏览器上使用。请告诉我,我可以调用使用IEAjax表单无法在IE上工作

+0

什么版本的IE?什么版本的jQuery? – Nzall

+0

你的控制台说什么? –

+0

使用Ajax的文件传输支持与IE 10及更高版本中的[XMLHttpRequest Level 2](http://caniuse.com/#feat=xhr2)一起添加。 –

回答

0

尝试使用setTimeout()IE像Ajax的形式,

$(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