草庐IT

original_series

全部标签

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();}但是,它不是,我也不想覆盖库存库代码。那么有没有办法在不触及原始功能代码的情况下执行上述操作?我会引用函数本身,仅此而已。编辑:我应该提到声明的函

javascript - Vue 和 Axios CORS 错误 No 'Access-Control-Allow-Origin' header is present on the requested resource

这个问题在这里已经有了答案:XMLHttpRequestcannotloadXXXNo'Access-Control-Allow-Origin'header(11个答案)关闭4年前。我目前遇到上述错误,我正在使用Axios向外部API发出GET请求。看完Mozilla文档,做了很多研究并尝试了不同的选择,我仍然没有任何改善。我已经将代码剥离回到基础:axios.get('URL.com',{headers:{Access-Control-Allow-Origin:*},auth:{username:'username',password:'password'},}).then(func

javascript - CORS header 'Access-Control-Allow-Origin' 不匹配...但确实匹配‼

我正在用Java制作一个非常简单的JSONAPI。它实际上是一个提供对象坐标的ProjectZomboidmod。这是我的HTTP处理程序的样子:publicclassJSONZomboidimplementsHttpHandler{@Overridepublicvoidhandle(HttpExchanget)throwsIOException{//HEADERSHeadersheaders=t.getResponseHeaders();headers.set("Content-Type","text/json");headers.set("Access-Control-Allow-