AnsweredAssumed Answered

AJAX

Question asked by kyleburnett on Apr 16, 2014
Latest reply on Sep 3, 2014 by pwalawal

Has anyone had any luck using AJAX with MSE?

 

I can get a successful connection in my Chrome REST tester, but just not via AJAX. Here's my code:

 

<script type="text/javascript">

 

  var APP_URL = 'https://172.28.35.134/api/'; ///contextaware/v1/maps/count';

  var username = 'username';

  var password = 'password'; 

 

  function make_base_auth(user, password) {

   var tok = user + ':' + password;

   var hash = btoa(tok);

   return "Basic " + hash;

  }

  $.ajax

   ({

  type: "GET",

  url: APP_URL,

  dataType: 'json',

  async: false,

  data: '{}',

  beforeSend: function (xhr){

  xhr.setRequestHeader('Authorization', make_base_auth(username, password));

  },

  success: function (){

  alert('Connected');

  }

  });

</script>

 

Any thoughts or advice?

Outcomes