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


基础教程推荐
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01