简体   繁体   English

客户端上的AJAX加载解决方法 跨源请求错误

[英]AJAX Load on the client side workaround | Cross Origin requests error

I am aiming to create a visual novel, "click" progression game. 我的目标是创建视觉小说“点击”进度游戏。 I am aiming to achieve that using purely HTML, CSS and JS. 我的目标是使用纯HTML,CSS和JS来实现这一目标。 The game is supposed to run only on the client side from index.html in the browser. 该游戏应仅在浏览器中index.html的客户端运行。

My question is, I am hitting up some trouble with those cross origin requests and I'm trying to figure out a solution from 2 weeks now, and i have no idea how to make this happen. 我的问题是,我在处理这些跨源请求时遇到了一些麻烦,并且我想从2周开始寻找解决方案,而且我不知道该如何实现。 Error "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource." 错误“仅协议方案支持跨源请求:http,数据,chrome,chrome扩展名,https,chrome-extension-resource。”

What i want to achieve is very simple. 我想要实现的非常简单。 Instead of using something like twine engine, i would like to write native, because it will be more productive and faster for me. 我不想使用诸如twine引擎之类的东西,而是想编写本机代码,因为它对我而言将更加高效和快捷。

Options i tried so far: 我到目前为止尝试过的选项:

  • JQuery Load - requires server jQuery加载-需要服务器
  • Wrote a pure XML Ajax load - CORS error. 编写了纯XML Ajax加载-CORS错误。 (so... server) (所以...服务器)
  • I started to write html into js files and load them instead, then use document.write or innerHTML to replace, but that can only get me so far and its hard to extend after 5 files. 我开始将html写入js文件并加载它们,然后使用document.write或innerHTML进行替换,但这只能使我到目前为止,并且很难扩展5个文件。

What can i do to get this running? 我该怎么做才能使它运行? I know C#, but before i move to .exe is there anyway i can get this done? 我知道C#,但是在转到.exe之前,我可以完成此操作吗? Will react.js work client side only and load components without CORS error? react.js将仅在客户端工作并且加载没有CORS错误的组件吗? Never tried the framework, because in the tutorials i see they use a webserver. 从未尝试过该框架,因为在教程中我看到它们使用网络服务器。

Any ideas? 有任何想法吗? Thanks beforehand! 预先感谢!

Will react.js work client side only and load components without CORS error? react.js将仅在客户端工作并且加载没有CORS错误的组件吗?

No, because it will still be another thing that runs in the browser and is subject to the limitations imposed by the browser. 不,因为它仍然是浏览器中运行的另一件事,并受浏览器的限制。

You need a server, a browser which doesn't impose those limitations, (something that sort of combines the two like Electron), to use a dirty hack like JSONP to load the files, or to wrap up all the files so they are embedded in the JS you load initially. 您需要一台服务器,一个没有强加这些限制的浏览器(某种将二者结合在一起的东西,例如Electron),使用像JSONP这样的肮脏黑客来加载文件,或者包装所有文件以便将它们嵌入在您最初加载的JS中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 服务器端的跨源请求 - Cross Origin requests at server side Chrome 65 阻止跨域<a download>。</a> <a download>强制下载的客户端解决方法?</a> - Chrome 65 blocks cross-origin <a download>. Client-side workaround to force download? 飞行前交叉原点请求中的错误 - Error in preflight Cross origin Requests 跨域请求到AWS S3的AJAX请求有时会导致CORS错误 - Cross-origin requests AJAX requests to AWS S3 sometimes result in CORS error 客户端验证和Ajax请求 - client side validations and ajax requests vs2008中没有错误但在Chrome中错误= XMLHttpRequest无法加载文件:仅支持HTTP的跨源请求 - no error in vs2008 but in Chrome Error= XMLHttpRequest cannot load file: Cross origin requests are only supported for HTTP 错误消息“ XMLHttpRequest无法加载。 跨源请求仅在AngularJS中支持HTTP - Error message 'XMLHttpRequest cannot load. Cross origin requests are only supported for HTTP in AngularJS' 在客户端js使用来自第三方的交叉源JSON? - Using cross origin JSON from third party on client side js? 在本地进行跨源请求 - Cross origin requests on local XMLHttpRequest无法加载https:// [website] .com不支持跨源请求 - XMLHttpRequest Cannot Load https://[website].com Cross Origin Requests are not supported
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM