javascript - How can i get external HTML with JS or jQuery -
this question has answer here:
- ways circumvent same-origin policy 11 answers
i trying html of external url jquery cannot code below work.
can 1 tell me how make work?
<script language="javascript" type="text/javascript"> $.ajax({ url: 'http://news.bbc.co.uk', type: 'get', success: function(res) { var headline = $(res.responsetext).find('a.tsh').text(); alert(headline); } }); </script>
crossbrowser access not allowed in ajax
you use jsonp has limitation
another solution create iframe , change url website want. when iframe loads innnerhtml of iframe , should provide result
<iframe id="urldetails" onload = "htmlcontent()" src=""></iframe> $("#urldetails").attr("src","http://news.bbc.co.uk"); function htmlcontent() { var urlinnercontent = $("#urldetails").html(); }
Comments
Post a Comment