The easiest way to access the received JSON data is to assign it to a document level variable in the xhrGet load function:
var fetchedData = null; function parseResponse() { } dojo.xhrGet({ url: "{{dataUrl}}dojo/LICENSE", handleAs: "json", preventCache: true, load: function(response){
Well no. Since then I have learned much better, and forgot to return and correct this answer, so it deserves to be credited.
The correct way to process data obtained from dojo.xhrGet, jQuery.ajax, or any other asynchronous data fetch is to write a function to process its results and pass it to xhrGet as load , for example:
var request = dojo.xhrGet({ url :'/disease_web/graphMlDownload/getEdgeInformation/', handleAs: "json", content : {edgeid : edgeId, graphname:this._canvas.path}, load: doSomethingWithMyEdges }); function doSomethingWithMyEdges(json_results) { console.log(json_results); }
source share