[英]Read properties file located on server from Javascript
我的服務器中有一個屬性文件。 使用 Javascript 或任何其他客戶端,最好是 JQuery,我可以加載它來獲取值嗎? 可能嗎?
The standard way to access server-side data from client-side Javascript is to pass it out through a controller on the server, preferably encoded in JSON, and use AJAX on the client side to request it from the server. 如果您不需要任何安全措施,您可以只從服務器公開 static 平面文件,而不是為其制作完整的 controller,然后解析 Z9E13B69D1D2DA927102ACAAAF7154 中的內容。
無法直接訪問服務器端文件,因為通常客戶端代碼無法訪問服務器的私有文件系統。
如果您的屬性文件可以通過網絡服務器訪問(例如: http://your-url/path/to/properties.xml )那么您可以簡單地托管一個腳本(http://your-url/path/to/script .html) 並使用 AJAX 獲取屬性文件並將其作為 XML 文檔處理(假設文件為 XML 格式)
請參閱 jQuery 文檔,了解如何解析 XML 響應並使用 AJAX Z497031794414A552435F901BAC.
Read this API Doc: http://api.jquery.com/jQuery.ajax/ it has some examples to give you a head start in fetching documents using AJAX
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.