Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display data from JsonRestStore
    text
    copied!<p>The following is the code sample I have written. I would like to get the data from REST services and print it on the screen. I could get the response from REST in the JSON format. But, I could not find the way to use store it in the JSONStore and use it. Please help me to resolve this issue.</p> <pre><code>dojo.provide("index.IndexService"); dojo.require("dojo.parser"); dojo.require("dijit.Editor"); dojo.require("dijit.form.Button"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.TabContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dojox.data.JsonRestStore"); var xhrArgs = { url: "http://localhost:8080/RestApp/service/customers", handleAs: "json", contentType : "application/json", load: function(data){ alert(data); }, error: function(error){ alert(error); } } dojo.ready(function(){ // Create a button programmatically: var button = new dijit.form.Button({ label: "View Transactions...", onClick: function(){ // Do something: dojo.byId("result1").innerHTML += "Functionality yet to be implemented! "; } }, "progButtonNode"); alert('hi'); var store = new dojox.data.JsonRestStore({target: "http://localhost:8080/RestApp/service/customers"}); alert(store); store.get(1).when(function(object){ alert(object); // use the object with the identity of 3 }); //var deferred = dojo.xhrGet(xhrArgs); //compliantStore = new dojox.data.JsonRestStore({deferred}); alert(deferred); }); </code></pre> <p>Returned JSON value is </p> <blockquote> <p>{"employees":{"customers":[{"city":null,"accountNo":null,"name":"Name 1","id":1},{"city":null,"accountNo":null,"name":"Name 2","id":2}],"count":2}}</p> </blockquote> <p>How would I retrive the values?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload