Javascript 使用AJAX解析页面内容
我正在React中开发一个项目,我需要调用AJAX来获取页面的源代码 我不熟悉AJAX,所以我看了这里: 他们使用以下方法从Github获取要点Javascript 使用AJAX解析页面内容,javascript,jquery,ajax,reactjs,Javascript,Jquery,Ajax,Reactjs,我正在React中开发一个项目,我需要调用AJAX来获取页面的源代码 我不熟悉AJAX,所以我看了这里: 他们使用以下方法从Github获取要点 componentDidMount: function() { $.get(this.props.source, function(result) { var lastGist = result[0]; if (this.isMounted()) { this.setState({ u
componentDidMount: function() {
$.get(this.props.source, function(result) {
var lastGist = result[0];
if (this.isMounted()) {
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}
}.bind(this));
},
我想更改它以检索我正在访问的页面内容(纯文本)
我该怎么做呢?阅读AJAX文档
做
应该做到这一点。请看,其中的共识是“不,他们不应该”!
$.get('http://example.com/my-url', function(result) {
console.log(result);
});