Ajax脚本可以访问不同网站的网页吗?
Ajax脚本可以访问不同网站的网页吗?例如我尝试遵循
xmlhttprequestobj.open("GET","google.com",true);
这段代码有什么问题吗?
Can an Ajax script access different website's webpage? for example i tried following
xmlhttprequestobj.open("GET","google.com",true);
What is wrong with this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,由于同源政策,它不能: http://en.wikipedia.org/wiki/Same_origin_policy
No, it cannot, due to the Same Origin Policy: http://en.wikipedia.org/wiki/Same_origin_policy
如果 endurl (在您的情况下.. google.com)支持以 jsonp 格式返回数据,则您的请求有效。
Your request is valid if the endurl (in your case.. google.com) supports returning data in jsonp format.
不,您无法访问其他域和主机的网页,即使我尝试了您尝试过的相同操作,由于安全原因浏览器不允许这样做。
No, you cannot access webpages of other domains and hosts, even i tried the same thing you tried, due to security reasons browsers do not allow so.