对铬的错误,当我尝试AJAX调用 [英] Error on chrome when I try AJAX call

查看:109
本文介绍了对铬的错误,当我尝试AJAX调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试做一个Ajax调用,我得到了错误的镀铬如下。

  

XMLHtt prequest无法加载的javascript:;。跨起源请求   仅支持协议方案:HTTP,数据,镀铬,   镀铬的扩展,HTTPS,铬扩展资源。

下面是code:

  $。阿贾克斯({
    键入:POST,
    数据:{P值:PID},
    缓存:假的,
    网址:xxx.in/yy/ajax.php
    成功:函数(数据)
    {
      $ modal.find(编辑内容。)HTML(数据)。
    }
 

解决方案

所有研究的特定错误信息显示主机网页不通过HTTP被加载:// URL,可能是一个文件:URL。该浏览器将不会在默认情况下,允许从一个文件跨起源请求:URL。

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

下面是全部指向了错误的URL类型被用来加载页面其他一些问题和解答有关的特定错误。

<一个href="http://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local">"Cross原产地请求仅支持HTTP&QUOT。错误加载本地文件时

<一个href="http://stackoverflow.com/questions/20904098/react-js-example-in-tutorial-not-working">React.js:例如,在教程中不工作

<一个href="http://stackoverflow.com/questions/8449716/cross-origin-requests-are-only-supported-for-http-but-its-not-cross-domain">Cross原产地请求仅支持HTTP,但它不是跨域

<一个href="http://answers.playcanvas.com/questions/833/cannot-load-model-due-to-cross-origin-request-being-blocked" rel="nofollow">http://answers.playcanvas.com/questions/833/cannot-load-model-due-to-cross-origin-request-being-blocked

https://groups.google。 COM /论坛/#!话题/ tincr换铬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

这篇关于对铬的错误,当我尝试AJAX调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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