Sau*_*ena 6 ajax jquery cross-domain
对于一个项目,我需要获取不同其他域的网页源代码.我试过以下代码:
$('#container').load('http://google.com');
$.ajax({
url: 'http://news.bbc.co.uk',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('a.tsh').text();
alert(headline);
}
});
Run Code Online (Sandbox Code Playgroud)
我仍然没有得到任何结果,只是一个空白的警报框.
Por*_*rco 11
默认情况下,所有浏览器都会限制跨域请求,您可以使用YQL作为代理来解决此问题.请参阅此处的指南:http://ajaxian.com/archives/using-yql-as-a-proxy-for-cross-domain-ajax