Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin

XMLHttpRequest Origin is not allowed by Access-Control-Allow-Origin(Access-Control-Allow-Origin 不允许 XMLHttpRequest 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

基础教程推荐