title: dojox.grid.DataGrid populated from Servlet
body: <p>I'd like to hava a Dojo dojox.grid.DataGrid with its data from a servlet.</p>
  
  <p>Problem: The data returned from the servlet does not get displayed, just the message "Sorry, an error has occured".</p>
  
  <p>If I just place the JSON string into the HTML, it works. ARRRRGGH.</p>
  
  <p>Can anyone please help me!</p>
  
  <p>Thanks
  Jeff Porter</p>
  
  <p>Servlet code...</p>
  
  <pre><code>public void doGet(HttpServletRequest req, HttpServletResponse resp) {
      res.setContentType("json");
      PrintWriter pw = new PrintWriter(res.getOutputStream());
      if (response != null) pw.println("[{'batchId':'2001','batchRef':'146'}]");
      pw.close();
  }
  </code></pre>
  
  <p>HtmL code...</p>
  
  <pre><code>    &lt;div id="gridDD" dojoType="dojox.grid.DataGrid" 
      jsId="gridDD" style="height: 600x; width: 100%;" 
      store="ddInfo" structure="layoutHtmlTableDDDeltaSets"&gt;
      &lt;/div&gt;      
  
      var rawdataDDInfo = ""; // empty at start
      ddInfo = new dojo.data.ItemFileWriteStore({
          data: {
              identifier: 'batchId',
              label: 'batchId',
              items: rawdataDDInfo
          }
      });
      &lt;script&gt;
      function doSelectBatchsAfterDate() {
      var xhrArgs = {
          url: "../secure/jsonServlet",
          handleAs: "json",
          preventCache: true,
          load: function(data) {
          var xx =dojo.toJson(data);
              var ddInfoX = new dojo.data.ItemFileWriteStore({data: xx});
              dijit.byId('gridDD').setStore(ddInfoX);
          },
          error: function(error) {
                  alert("error:" + error);
          }
      }
  
      //Call the asynchronous xhrGet
      var deferred = dojo.xhrGet(xhrArgs);
      }
      &lt;/script&gt;
  &lt;img src="go.gif" onclick="doSelectBatchsAfterDate();"/&gt;
  </code></pre>