2012-03-27 2 views
0

외부 URL에서 일부 JSON을 가져 오려고합니다. 이것은 dojo 문서의 예제에서 트위터 요청과 잘 작동합니다.dojo.io.script.get의 콜백 함수

콜백 함수에는 문제가있는 것 같아요. 필요한 곳이 어디에 있는지 알 수 없기 때문입니다. 이 문 언급하는

JSON: 
{ 
    "returnValue": true, 
    "timeStamp": 1332858447300, 
    "eventPhase": 0, 
    "target": null, 
    "defaultPrevented": false, 
    "srcElement": null, 
    "type": "load", 
    "cancelable": false, 
    "currentTarget": null, 
    "bubbles": false, 
    "cancelBubble": false 
} 

답변

0

을 :

{"upcoming":[]} 

그리고 내가 그것을 호출 방법은 다음과 같습니다 : 출력 내가 얻을 것

 function getJSON(){ 
    // Look up the node we'll stick the text under. 
    var targetNode = dojo.byId("results"); 

    // The parameters to pass to xhrGet, the url, how to handle it, and the callbacks. 
    var jsonpArgs = { 
    url: url, 
    load: function(data){ 
     console.log(data); 
     // Set the data from the search into the viewbox in nicely formatted JSON 
     targetNode.innerHTML = "<pre>" + dojo.toJson(data, true) + "</pre>"; 
    }, 
    error: function(error){ 
     targetNode.innerHTML = "An unexpected error occurred: " + error; 
    } 
    }; 
    test = dojo.io.script.get(jsonpArgs); 
} 
dojo.ready(getJSON); 

개미처럼

json으로 본다 당신의 모범에서?

// The parameters to pass to xhrGet, the url, how to handle it, and the callbacks. 

그렇다면 "콜백"은로드 및 오류 기능입니다.

+0

dojo.io.script에 설명 된 콜백 함수를 참조하십시오. 글쎄, 문제는 json 데이터와 관련된 서버의 누락 콜백 함수라고 생각합니다. 내가 올바르게 이해했다면 JSON 데이터를 "포함"하는 서버에서 콜백 함수를 수신해야합니다. 맞습니까? 이것이 맞다면 문제의 해결책이 있습니다. :) – knacker123