I am trying to get the JSON response from a URL having authentication, The code is mentioned below
$.getJSON({
'url': 'http://test.etravelsmart.com/etsAPI/api/getStations',
'beforeSend': function(xhr) {
//May need to use "Authorization" instead
xhr.setRequestHeader("Authentication","Basic " + encodeBase64("*****" + ":" + "****"))
},
success: function(result) {
alert(result);
$.each(result, function(i, field) {
var StationId = field.stationId;
var StationName = field.stationName;
$("#txtLabourId").append("<option>" + StationName + "</option>");
});
}
});
I am trying to display the values in a
<select id="txtLabourId"></select>
But having authentication i am not getting the response. All help appreciated