XMLHttpRequest的;交叉来源请求仅支持协议方案:http,data,chrome,chrome-extension,https,chrome-extension-resource [英] XMLHttpRequest; Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource

查看:898
本文介绍了XMLHttpRequest的;交叉来源请求仅支持协议方案:http,data,chrome,chrome-extension,https,chrome-extension-resource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


XMLHttpRequest无法载入javascript:;。交叉原点请求仅支持
协议方案:http,data,chrome,
chrome-extension,https,chrome-extension-resource。

以下是代码:

  $。ajax({
type:POST ,
data:{pvalue:pid},
cache:false,
url:xxx.in/yy/ajax.php,
success:function(data)
{
$ modal.find('。edit-content')。html(data);
}


解决方案

对特定错误消息的所有研究表明,主机网页未通过http:// URL加载,可能是文件:URL。默认情况下,浏览器不允许来自文件:URL的跨源请求。



您需要通过Web服务器加载网页,而不是通过如果您想使用ajax请求,则使用文件系统。



以下是有关该特定错误的其他所有问题和答案,均指向wr ong类型的URL用于加载页面。



只有HTTP支持跨源请求。加载本地文件时出错



React.js:教程中的示例不工作

跨源请求只支持HTTP,但不支持跨域



http://answers.playcanvas.com/questions/833/cannot-load-model-due-to-cross-origin-request-being-blocked



https://groups.google.com/forum/#!topic/tincr-for-chrome-devtools/nA9k2qh7F-g


When I try to do a ajax call, I got the error on chrome below.

XMLHttpRequest cannot load javascript:;. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Here is code:

$.ajax({
    type: "POST",
    data: {pvalue : pid},
    cache: false,
    url: "xxx.in/yy/ajax.php",
    success: function(data)
    {
      $modal.find('.edit-content').html(data);
    }

解决方案

All research into that specific error message suggests that the host web page is not being loading via an http:// URL and is probably a file: URL. The browser will not, by default, permit cross origin requests from a file: URL.

You need to load the web page through your web server, not via the file system if you want to use ajax requests.

Here are some other questions and answers about that specific error that all point to the wrong type of URL being used to load the page.

"Cross origin requests are only supported for HTTP." error when loading a local file

React.js: Example in tutorial not working

Cross origin requests are only supported for HTTP but it's not cross-domain

http://answers.playcanvas.com/questions/833/cannot-load-model-due-to-cross-origin-request-being-blocked

https://groups.google.com/forum/#!topic/tincr-for-chrome-devtools/nA9k2qh7F-g

这篇关于XMLHttpRequest的;交叉来源请求仅支持协议方案:http,data,chrome,chrome-extension,https,chrome-extension-resource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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