title: SharePoint 365 REST API basic handling - put result in div?
body: <p>Very new to all this.</p>
  
  <p>As a learning exercise I'm trying to update a div id "message" on a SharePoint page with a result returned from a REST API call.</p>
  
  <p>I can copy/paste my query url into my browser and get a result so I can't imagine that's the problem, but when I embed the following script I can't seem to get the success or failure to do anything.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <pre><code>&lt;div id="message"&gt;&lt;/div&gt;
  
  &lt;input type="button" value="Get" onclick="doGet();" &gt;
  &lt;script&gt;
  
  function doGet()
    {
  
  var call = jQuery.ajax({
          url: "https://X/sites/forms/_api/web/lists/getByTitle('Y')/items?$select=Z&amp;$top=1",
          type: "GET",
          dataType: "json",
          headers: {
              Accept: "application/json;odata=verbose"
          }
      });
  
      call.done(function (data,textStatus, jqXHR) {
      alert("CallDone");
      var message = jQuery("#message");
  
      jQuery.each(data.d.results, function (index, item) {
      message.append("&lt;br/&gt;");
      message.append(item.Z);
      $get("message").innerHTML = item.Z;
  
      });
   });
      call.fail(function (jqXHR,textStatus,errorThrown){
      alert("Call failed");            
      alert("Error retrieving: " + errorThrown);  
  
      });
  
  }
  
  
  &lt;/script&gt;
  </code></pre>