[英]send a ajax GET request to a https website with username and password
I want to access a website and get the anchor tags from it using an "ajax call" as follows:我想访问一个网站并使用“ajax调用”从中获取锚标签,如下所示:
$.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.但是我在“http”网站上尝试了相同的代码,它工作正常。
It's because https
is something different than http
, and Facebook just like many other websites uses cookies for authenticating.这是因为https
与http
不同,Facebook 就像许多其他网站一样使用 cookie 进行身份验证。 You have to first authenticate in https://facebook.com
and then you can get data back.您必须首先在https://facebook.com
进行身份验证,然后才能取回数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.