티스토리 뷰

반응형

크롬에서는 되는데, 익스플로러에서는 데이터가 깨지는 현상,

이 문제를 해결하고자 하루를 보냈습니다. 구글링으로 여러자료를 찾다가 결국 해결한 내용을 담아볼까 합니다. 1일의 개고생이 그래도 해결되서 마음이 불편하지는 않네요.

 

각설하고, 익스플로러에서 전달받는 자료를 같은 화면의 다른 php로 전달하는 경우... 실제 사용한 프로그램의 내용입니다.

$(function() {

    $("#gunbbang").on("click", function() {
        $("#detail").load("./gunbbang.php");
    });
    $("#screenexitmake").on("click", function() {
        $("#detail").load("./screenexitmake.php");
    });	
    $("#egimake").on("click", function() {
        $("#detail").load("./egimake.php");
    });		
    $("#gotorail").on("click", function() {
 var target = document.getElementById("item_sel"); 
 // alert(target.options[target.selectedIndex].value);
 var sendData = target.options[target.selectedIndex].value ;
            var ua = window.navigator.userAgent;
            var postData; 
            sendData = "./rail.php?rail=" + sendData;

            // 윈도우라면 ? 
            if (ua.indexOf('MSIE') > 0 || ua.indexOf('Trident') > 0) {
                postData = encodeURI(sendData);
            } else {
                postData = sendData;
            }	

	// alert(postData);
        $("#guiderail_area").load(postData);
    });		
});		

위의 코드 중에서 encodeURI 이것이 핵심입니다.

구글링으로 자료를 찾다가 이런 글을 보게 되었지요.

// 윈도우인지 다른 브라우저인지 확인 
            var ua = window.navigator.userAgent;
            var postData;
            // 윈도우라면 ? 
            if (ua.indexOf('MSIE') > 0 || ua.indexOf('Trident') > 0) {
                postData = encodeURI(sendData);
            } else {
                postData = sendData;
            }

            $.ajax({
                url: "thumnailUpload.php", // Url to which the request is send
                type: "POST",             // Type of request to be send, called as method
                data: postData, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
                contentType: false,       // The content type used when sending data to the server.
                cache: false,  

 

여기서 힌트를 얻어서 encodeURI란 것이 '다른 파일을 열때 그 내용을 깨지지 않게 하는구나'라고 알았습니다.

익스플로러 사용할때는 이것이 안되면 멘붕옵니다.

즐프하시기 바랍니다.

반응형
댓글