草庐IT

original-package

全部标签

javascript - CORS 问题 : Getting error "No ' Access-Control-Allow-Origin' header is present"when it actually is

我怀疑为我的应用程序提供服务的后端是否重要,但如果你关心的话,我正在使用rack-cors使用Rails4.0应用程序。使用jQuery,我向我的应用发送一个PATCH请求,如下所示:$.ajax({url:"http://example.com/whatever",type:"PATCH",data:{something:"somethingelse"}})当我从Chrome触发此调用时,我看到一个成功的OPTIONS请求发出,它从我的服务器返回这些header:Access-Control-Allow-Credentials:trueAccess-Control-Allow-Hea

javascript - 玩! 2.4 : How to allow CORS from origin file://

我正在使用play2.4制作公共(public)RESTAPI。我添加了允许所有来源和header的CORS过滤器。从application.conf中查看:play.filters{#CORSfilterconfigurationcors{#Thepathprefixestofilter.pathPrefixes=["/"]#Theallowedorigins.Ifnull,alloriginsareallowed.allowedOrigins=null#TheallowedHTTPmethods.Ifnull,allmethodsareallowedallowedHttpMetho

javascript - 如何使用 Access-Control-Allow-Origin : https://www. example.com?

我想从HTTP网页进行HTTPS调用。我希望通过Access-Control-Allow-Origin解决这个问题。我该如何使用它? 最佳答案 在HTTPS页面(您从HTTP页面请求)设置header:Access-Control-Allow-Origin:http://www.example.com您可以在PHP中执行此操作:或者,如果这不起作用,您可以在HTTP服务器(请求的来源)上创建一个文件来下载和显示内容,这可以在PHP中使用:我不建议这样做,因为它需要额外的带宽并且不是好的做法,只有在您不能执行第一个选项时才应使用它。此

javascript - 如何使用 XMLHttpRequest 设置 Access-Control-Allow-Origin header

这是根据提供的示例验证geoJSON的代码:functionprocessSuccess(data){if(data.status==="ok")console.log("YoujustpostedsomevalidgeoJSON");elseif(data.status==="error")console.log("TherewasaproblemwithyourgeoJSON"+data.message);}functionprocessError(data){console.log("TheAJAXrequestcouldnotbesuccessfullymade");}$.aj

javascript - 访问 ' from origin ' null 处的脚本已被 CORS 策略阻止

因此,当我尝试从另一个javascript文件导入类时,我在控制台中遇到这样的错误:AccesstoScriptat'file:///home/../.../JavaScript/src/index.js'fromorigin'null'hasbeenblockedbyCORSpolicy:Invalidresponse.Origin'null'isthereforenotallowedaccess.在我的html文件中,我以这种方式添加脚本文件:我的index.js看起来像这样:importPaddlefrom"/src/paddle";letcanvas=document.getE

javascript - 收到无效响应。因此不允许访问 Origin 'null'

我正在学习一本书的例子,因此代码非常简单。这是代码:我在Chrome控制台中看到一个错误:$(function(){$(".lang").change(function(){varelement=$(this);varid=element.attr("value");if(id=='english'){$.ajax({type:"GET",url:"jsfiles/english.js",dataType:"script"});}returnfalse;});}); 最佳答案 来源null表示您直接从文件系统加载HTML文档。没有H

javascript - Google 的 Places API 和 JQuery 请求 - 来源 http ://localhost is not allowed by Access-Control-Allow-Origin

我正在为我想到的一个项目做一些测试,该项目涉及使用附近的地方。所以我和大个子一起去了,开始摆弄谷歌的PlacesApi。我正在为我的map使用带有openstreettiles的传单。现在一切都很好,直到我尝试使用该死的东西。varlat=coords.lat;varlng=coords.lng;varapiUrl="https://maps.googleapis.com/maps/api/place/nearbysearch/json";vardata={key:'AIzaSyBl8bmE8kQT7RjoXhP6k2yDti44h9-fSUI',location:lat+','+ln

javascript - XMLHttpRequest 无法加载,请求的资源上不存在 'Access-Control-Allow-Origin' header

这个问题在这里已经有了答案:Howtomakecross-domainAJAXcallstoGoogleMapsAPI?(1个回答)关闭6年前。XMLHttpRequestcannotloadhttp://maps.googleapis.com/maps/api/distancematrix/xml?origins=Affenhausen&destinations=Achenkirch&mode=driving&language=de-DE&sensor=false.No'Access-Control-Allow-Origin'headerispresentontherequested

javascript - Access-Control-Allow-Origin 不适用于同一域内的 iframe

我正在尝试访问子域中的iframe并遇到跨域错误。这是示例.mydomain.com/iframe_test.html的代码:$(document).ready(function(){setTimeout(function(){$('#innerdiv',$('iframe').contents()).hide();},5000);});这是example2.mydomain.com/welcome.php的代码:hello$('#innerdiv',$('iframe').contents()).hide()行执行时,出现如下错误:UncaughtSecurityError:Fail

javascript - JS : Call a function after another without touching the original function?

我正在尝试在特定页面上扩展第三方库,但我不想更改任何第三方代码。我知道第三方库在发生某些事情时调用的函数的名称,所以如果我希望自己的自定义代码在此之后执行,我该怎么做?第三方库有:functioneventFinished(args){//librarystuffhere}现在,如果这是我自己的代码,我会这样做:functioneventFinished(args){//librarystuffhereMyCustomFunction();}但是,它不是,我也不想覆盖库存库代码。那么有没有办法在不触及原始功能代码的情况下执行上述操作?我会引用函数本身,仅此而已。编辑:我应该提到声明的函