使用AJAX来读本地文件 [英] Using AJAX to read local files

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

问题描述

我是一个新手,AJAX,只是想确认:如果我有我的所有code我的桌面上的文件夹中,我使用AJAX在HTML中的DIV输出文件的内容,是有可能通过AJAX或文件访问本地文件应该是对服务器?

I'm a novice to AJAX and just want to confirm: if I have all my code in a folder on my desktop and I am using AJAX to output file content in a div in HTML, is it possible to access local files through AJAX or file should have to be on server?

我只是测试AJAX功能的第一次,我所面临的问题,因为它的示值误差拒绝访问的.js文件

I am just testing AJAX functionality for the first time and i am facing problem as its showing error "Access denied " in .js file

推荐答案

由于安全原因JavaScript的访问文件系统在客户机上被限制 - 考虑你是否会想(别人的)的JavaScript读取你的敏感文件

For security reasons JavaScript's access to the file system on the client is restricted - consider whether you would want (somebody else's) JavaScript to read your sensitive documents.

即使是最好的一个现实的拓扑结构的工作,防止可能从那里担任了真正的系统的服务器服务的东西。

Even when experimenting it's best to work with a realistic topology, serve things from the server that would be served from there in the real system.

这真的很容易建立一个Web服务器,如Apache来指向您的开发目录,所以服务器就是你变相的桌面。因此,编辑/测试周期非常快。

It's really easy to set up a web server such as Apache to point to your development directory, so the "server" is just your desktop in disguise. Hence the edit/test cycle is really quick.

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

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