這是我的Django的項目結構:Django項目結構和js目錄調用?
Project
-app_ABC
-json_data
-filter_saved.txt
-site_media
-css
-images
-scripts
-search.js
在我的腳本(search.js) - >我要創建一個腳本,可以寫的內容文件作爲JSON格式:
function WriteJSONFile(str){
var fh = fopen("json_data/filter_saved.txt", 3);//Open the file for writing
// If the file has been successfully opened
if(fh!=-1) {
fwrite(fh, str); // Write the string to a file
fclose(fh); // Close the file
}
}
$(document).ready(function(){
$("#save_filter").click(function(){
var filter_saved = []
var customer_type_selected = $('#id_customer_type :selected').text();
var list_tag_selected = $("#tag_checked").val();
var filter_name = $("#put_filter_name").val();
filter_saved_JSON = {
"pk":autoincrement,
"customer_type": customer_type_selected,
"tag": list_tag_selected
};
WriteJSONFile(filter_saved_JSON);
});
});
我的問題是
var fh = fopen("json_data/filter_saved.txt", 3);//Open the file for writing
Where "filter_saved.txt" Could I put into directory?
我試圖在許多項目目錄的地方(我使用Ubuntu)
我得到了一個錯誤:
fopen is not defined
[Break on this error] var fh = fopen("json_data/filter_saved.txt", 3);//Open the file for writing\n
誰能幫助我?
謝謝:)
也許你不明白我的問題或我的寫作? :) – kn3l 2009-12-25 03:14:53
您正在嘗試從位於客戶端上運行的JavaScript的位於服務器上的文件打開文件描述符。這是不正確的? – ironfroggy 2009-12-25 03:19:34
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm只是爲了這樣.. – kn3l 2009-12-25 03:20:31