I want to access a website and get the anchor tags from it using an “ajax call” as follows:
$.ajax({
url: 'https://www.facebook.com/',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('a').text();
alert(headline);
}
});
But i get headline as blank.
However i try the same code with a “http” website, it works fine.
It’s because
httpsis something different thanhttp, and Facebook just like many other websites uses cookies for authenticating. You have to first authenticate inhttps://facebook.comand then you can get data back.