title: Azure Mobile Service and Javascript
body: <p>Hi there i am stuck and somehow don't find the solution. It seems simple but, well ok. Here it goes. I have a mobile service in Azure and i want to reach that one with javascript. How do i get around the 401 Unauthorized? I tried with the documentation supplied from MS but no luck. This is what i got so far (adding the key to the url is not working of course) what can i add to get it to work?</p>
  
  <pre><code>var client = new WindowsAzure.MobileServiceClient(
  "https://cdshop.azure-mobile.net/",
  "vGpqzyApJXXXXXXXXblQCWne73"
  );
  
  var getJSON = function (url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.open('get', url, true);
  xhr.responseType = 'json';
  xhr.onload = function () {
      var status = xhr.status;
      if (status == 200) {
          callback(null, xhr.response);
      } else {
          callback(status);
      }
  };
  xhr.send();
  };
  
  
  $(function () {
  $('#clickme').click(function () {
  
      getJSON('http://cdshop.azure-mobile.net/api/cds/total?key=vGpqzyApJXXXXXXXXblQCWne73', function (err, data) {
  if (err != null) {
      alert('Something went wrong: ' + err);
  } else {
      alert('Your Json result is:  ' + data.result);
      result.innerText = data.result;
  }
      });
  });
  });
  </code></pre>