使用jQuery读/写文件 [英] Read/write to file using jQuery
问题描述
是否有一种让jQuery在文件中获取信息的方法?是否有可能?怎么样?
Is there a way to get jQuery to get information to and from a file? Is it possible? How?
推荐答案
否,JavaScript无法访问写入文件,因为至少可以说这将带来巨大的安全风险.但是,如果您想在服务器端获取/存储信息,则可以肯定地对PHP/ASP/Python/etc进行Ajax调用.然后可以在服务器中获取/存储数据的脚本.如果您打算将数据存储在客户端计算机上,那么仅使用JavaScript是不可能的.我怀疑Flash/Java也许可以,但是我不确定.
No, JavaScript doesn't have access to writing files as this would be a huge security risk to say the least. If you wanted to get/store information server-side, though, you can certainly make an Ajax call to a PHP/ASP/Python/etc. script that can then get/store the data in the server. If you meant store data on the client machine, this is impossible with JavaScript alone. I suspect Flash/Java may be able to, but I am not sure.
如果您只是想在不可靠的时间内针对特定用户存储少量信息,我认为您想要
If you are only trying to store a small amount of information for an unreliable period of time regarding a specific user, I think you want Web Storage API or cookies. I am not sure from your question what you are trying to accomplish, though.
这篇关于使用jQuery读/写文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!