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
Asked
Active
Viewed 93 times
2 Answers
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
});
}
});

Marius Bakowski
- 115
- 3
-
setting the res to html or text? – Jony S Apr 08 '16 at 19:55
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