本地文件的跨域请求 [英] Cross-origin request for local file

查看:81
本文介绍了本地文件的跨域请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在浏览器中打开本地html文件.javascript可以正常工作,但是ajax停止工作,并且XMLHttpRequest提供了跨源错误.有没有一种方法可以从本地目录运行ajax.对我来说,它必须仅从本地文件运行.

I need to open a local html file in the browser. The javascript works fine but ajax stops working and XMLHttpRequest gives a cross origin error. Is there a way to run ajax from local directory. It is necessary for me that it is run from local file only.

谢谢

推荐答案

对于任何想知道的人,我都必须在应用程序中运行服务器来提供js文件.好像不运行服务器就不可能做到这一点.如果有人知道另一种方式,请告诉.

For anyone who wants to know, I had to run a server in the app to serve the js files. Seems like it's not possible to do it without running a server. If anyone knows of another way, do tell.

这篇关于本地文件的跨域请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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