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
问题描述
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用于加载页面。
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
https://groups.google.com/forum/#!topic/tincr-for-chrome-devtools/nA9k2qh7F-g
这篇关于XMLHttpRequest的;交叉来源请求仅支持协议方案:http,data,chrome,chrome-extension,https,chrome-extension-resource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!