我想在URL中获取rss内容: https://www.weatherworksinc.com/rss.xml。
function Ajax( ) {
var url = 'https://www.weatherworksinc.com/rss.xml';
$.ajax(url, {
type:"GET",
dataType: 'jsonp',
crossDomain: true,
success:function(data){
alert(data);
},
error: function (e) {
alert("error");
}
});
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- in my local file it is -->
<!-- <script src="http://127.0.0.1/jquery-3.3.1.min.js"></script> -->
<input type="button" value="show content" onclick="Ajax();" />
具有jquery的ajax函数,获取它并在成功时提醒数据。
遇到错误信息:
jquery-3.3.1.js:9679 Cross-Origin Read Blocking (CORB) blocked
cross-origin response https://www.weatherworksinc.com/rss.xml?
callback=jQuery3310611427014381984_1535596672985&_=1535596672987
with MIME type text/plain. See
https://www.chromestatus.com/feature/5629709824032768
for more details.
我为跨域问题设置了JSONP
。
如何获得rss.xml内容?