-1
我想通过ajax间隔/不同域中的刷新存储数据(明文)。例如,这是不同的域名:http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong通过jquery从跨域获取正文内容
我想通过ajax间隔/不同域中的刷新存储数据(明文)。例如,这是不同的域名:http://live-radio01.mediahubaustralia.com/3SALE/mp3/currentsong通过jquery从跨域获取正文内容
你可以用“任何地方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 - 预览&代码
也许这会有所帮助。
$.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
});
}
});
设置资源到HTML或文本? –