2013-02-13 1 views
0

저는 Jquery에서 매우 새롭고 colorbox가 특히 유용합니다.json 형식의 colorbox에서 데이터를 가져옵니다.

{"oslc_cm:message":"oslc_cm:create","oslc_cm:results":[{"oslc_cm:label":"TA41071:Test", "rdf:resource":"https://example.com/TA41071"}]} 

질문은 다음과 같습니다 : 나는하여 colorbox 엽니 다 사용하고 있습니다 : 내가 iframe을 사용하고있는 경우 colorbox 내에서 정보를 제출 한 후

jQuery().colorbox({ 
     href: 'http://example.com#oslc-core-postMessage-1.0', 
     iframe:true, 
     width:"1100px", 
     height:"80%" 
    }); 

을, 나는 다음을 얻고 어떻게 할 수 colorbox에서 json 값을 얻었습니까? 지금 당장 colorbox는 열린 채 빈 채로 남아 있고 아무 일도 일어나지 않습니다.

function createListener() 
{ 
window.addEventListener('message', 
    function (event) { 
    try { 
    jQuery().colorbox.close(); 
    var message = event.data; 
    if (message.indexOf("oslc-response:")>-1) { 
     message=message.substring(14); 
    } else { 
     alert('Error. return message should start with "oslc-response:".'); 
     return; 
    } 
    handleMessage(message); 
    } catch (e) { 
    // ignore: access exception when trying to access window name 
    } 
    } 
, false); 
} 

(function($) 
{ 
$(document).bind('cbox_load', createListener());   
}) (jQuery); 
:

답변

0

나는 다음을 수행하여 JSON을 얻을 수 있었다