API call via Javascript
I have an API that I need to call from JavaScript. The error I am getting is No 'Access-Control-Allow-Origin' . I think that this may be because of the need for the proxy tunneling routine.
So what I am trying to to do is pass a song id that is returned by one API and mapped to a page and then find the corresponding song name using this Javascript API call.
here is the javascipt ---(function(context) {
Song_Helper = {};
Code: Select all
Song_Helper.getSongInfo = function(songid) {
var result = [];
$.ajax('[url=http://dev.touchtunes.com/music/song?song_id]http://dev.touchtunes.com/music/song?...[/url]=' + songid + '&api_key=ulzuxxxxxxmykey', {
type: 'GET',
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
},
success: function(data) {
result = data;
},
complete: function(resp) {
console.log(resp);
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
return result;
};
context.Song_Helper = Song_Helper;
})(window);