由于跨域限制,您无法使用AJAX直接访问html.
但是,您可以使用Yahoo YQL选择所需页面的部分,并在jsonp数据中返回该html .
示例返回stackoverflow主页上的问题列表
var url='http://query.yahooapis.com/v1/public/yql?q=select * from html where url=\'http://stackoverflow.com/\' and xpath=\'//div[@id="question-mini-list"]//h3//a\'&format=json&callback=?';
$.getJSON( url, function(data){
$.each(data.query.results.a, function(){
$('body').append('<div><a href="http://stackoverflow.com'+this.href +'">'+this.content+'</a></div>')
})
})
Run Code Online (Sandbox Code Playgroud)
YQL文档:http://developer.yahoo.com/yql/guide/index.html