2011. 8. 25. 11:59

Jquery를 사용한 비동기화 구현

function xDomainProc(puzlNum){
    var tmp_ifr = $('<iframe />')
       .attr({'name':'temporary_ifr','id':'temp_ifr'})
        .hide()
       .load(function() {
                   $('#temporary_frm').remove();
                   var resetFlag = $('#temp_ifr').contents().find('#resetFlag').html();
                   var firstAccess = $('#temp_ifr').contents().find('#firstAccess').html();
                   var success = $('#temp_ifr').contents().find('#success').html();

if(success){
                    $('.iconpopup2').hide();
                    $('.puzzleeventPopup2 p:eq(0)').text('<%=iPuzlCnt+1%>')
                    $('.puzzleeventPopup2').show();
/*
                    if(firstAccess == "true"){
                    $('.puzzleeventPopup2').hide();
                    $('.puzzleeventPopup1').show();
                    }else if(resetFlag == "true"){
                    $('.puzzleeventPopup3 p:eq(0)').text('<%=iComplPuzl+1%>')
                    $('.puzzleeventPopup2').hide();
                    $('.puzzleeventPopup3').show();
                    }
*/ 
                   }else{
                    alert('fail');
                   }
                   //$(this).remove();
               });
var tmp_frm = $('<form />')
       .attr({'id':'temporary_frm',
               'action':'url',
               'method':'post',
               'target':'temporary_ifr'})
       .append($('<tag/>'))

$('body').append(tmp_ifr).append(tmp_frm);
//$('body').append(tmp_frm);
//tmp_frm.submit();
    }