XMLHttpRequest Origin is not allowed by Access-Control-Allow-Origin(Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin)
问题描述
我正在尝试通过 HTTP 从 JavaScript 获取一些简单的文本:
I'm trying to fetch some simple text over HTTP from JavaScript:
$(function() {
$.get("http://mydomain.com/path", function(result) {
console.log(result);
});
});
结果应该是text/html
,但基本上只是一个简单的键值字符串,没有任何HTML标签.该页面由我控制,但由第三方(闭源)提供,因此我无法修改提供此页面的 Java.
The result should be text/html
, but is basically only a simple key-value string, no HTML tags whatsoever. The page is in my control, but is supplied by a third-party (closed-source) so I can't modify the Java that serves out this page.
如何从 JavaScript 获取此页面的内容?
How can I get the contents of this page from JavaScript?
推荐答案
你只需要使用 PHP/ASP 你的服务器端语言来检索跨域请求或使用由 Yahoo! 创建的跨域 ajax 服务等服务.
You've simply gotta use either PHP/ASP your serverside language to retrieve the cross-domain request or use a service such as a cross domain ajax service created by Yahoo!.
它使用 JSONP,它允许执行非常严格的跨域请求,但来自 Yahoo!他们将检索互联网上的任何页面.
It uses JSONP which is allowed to do very strict cross-domain requests, but asking from Yahoo! they will retrieve any page on the internet.
http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
这篇关于Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin


基础教程推荐
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01