Access-Control-Allow-Origin不允许使用XMLHttpRequest Origin [英] XMLHttpRequest Origin is not allowed by Access-Control-Allow-Origin

查看:170
本文介绍了Access-Control-Allow-Origin不允许使用XMLHttpRequest Origin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过HTTP从HTTP获取一些简单文本:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆