-1

I want to store the data (plaintext) through ajax interval/refresh from a different domain. Eg. This is the different domain: http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong

Jony S
  • 129
  • 1
  • 1
  • 9

2 Answers2

0

Maybe this will help.

$.ajax({
    url: "http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong",
    type: 'GET',
    success: function(res) {
        $.ajax({
            url: "http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong",
            type: 'POST',
            data:res
        });
    }
});
0

You can achieve this with "CORS Anywhere" explained here: Loading cross domain endpoint with jQuery AJAX

So, with code used from that other post. Yours would look like this:

$(document).ready(function() {
  $.ajaxPrefilter(function(options) {
    if (options.crossDomain && jQuery.support.cors) {
      var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
      options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
      //options.url = "http://cors.corsproxy.io/url=" + options.url;
    }
  });

  $.get('http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong', function(response) {
    console.log(response);
    $("#viewer").html(response);
  });

});

Plnkr.co - Preview & code

Community
  • 1
  • 1
Sølve T.
  • 4,159
  • 1
  • 20
  • 31