title: How to parse JSON using DOJO AJAX and REST
body: <p>I am trying to send a request to a REST server using DOJO AJAX, however I get a null object as result (console):</p>
  
  <p>You CLICKED = click clientX=34, clientY=13
  JSON loaded from server: null</p>
  
  <p>Here is my code:</p>
  
  <pre><code>// JavaScript Document
  
  // load requirements for declarative widgets in page content
  require([   "dojo/parser",
          "dojo/dom",
          "dojo/domReady!",
          "dijit/form/Button"
          ]);
  
  
  // Start initializing
  dojo.ready(function(){
  
  dojo.connect (
                  aBut1,
                  "onClick",
                  function(e){
  
                      console.log('You CLICKED = ', e);
                      dojo.xhrGet({
                                  // The URL of the request
                                  url: "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/find",
                                  // Handle the result as JSON data
                                  handleAs: "json",
                                  // content
                                  content: {f:"json", searchText:"new", contains:"true", searchFields:"state_new", layers:"2", returnGeometry:"false" },
                                  // The success handler
                                  load: function(jsonData) {
                                      // Create a local var to append content to
                                      console.info("JSON loaded from server:  ", jsonData);
  
                                  },
                                  // The error handler
                                  error: function() {
                                      console.log('JSON log Error');
                                  }
                              });
  
                  });
  
  
  }); // End dojo.ready
  </code></pre>
  
  <p>This is the REST url I would like to use:</p>
  
  <p><a href="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/find?searchText=new&amp;contains=true&amp;searchFields=state_name&amp;sr=&amp;layers=2&amp;returnGeometry=false&amp;f=json" rel="nofollow">http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/find?searchText=new&amp;contains=true&amp;searchFields=state_name&amp;sr=&amp;layers=2&amp;returnGeometry=false&amp;f=json</a></p>
  
  <p>I save the result of this URL in a json file and AJAX works reading that file and returning an object with 4 items. It is not using REST URL.</p>
  
  <p>Thank you </p>