2016-04-08 77 views

回答

0

你可以用“任何地方CORS”实现这一解释在这里:Loading cross domain endpoint with jQuery AJAX

因此,与其他岗位使用的代码。你应该是这样的:

$(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 - 预览&代码

0

也许这会有所帮助。

$.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

设置资源到HTML或文本? –