2014-03-24 2 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를 제외한 모든 브라우저에서 작동합니다. , 내가 IEIE에서 Ajax 양식이 작동하지 않습니다.

+0

어떤 버전을 알려주세요? jQuery의 어떤 버전입니까? – Nzall

+0

본체가 말하는 내용은 무엇입니까? –

+0

Ajax를 사용한 파일 전송 지원은 IE 10 이상에있는 [XMLHttpRequest Level 2] (http://caniuse.com/#feat=xhr2)와 함께 추가되었습니다. –

답변

0

시도 같은 IE에 대한 setTimeout()를 사용할 수를 사용하여 아약스 양식을 호출 할 수 있습니다

$(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 IE와 IE의 Jquery: change event to input file on IE

관련 문제