here is what i want to do
i use codeigniter directory_map() function to map a folder save it as $map;
$map = directory_map($this->rootdir.$this->session->userdata('user_name'));
then i encode the $map and echo it out
echo $dir = json_encode($map);
what i want is save the $dir somehow.so when user open one of the folder i can use js to get the folder's content from the saved $dir json file, instead of communicate to server.if this make sense then how can i save the $dir json file or how to get it in the js file.
is there a better way to do that?
I personally use the method mentioned here , which is basically along the following outline:
Update: (I think I confused you a bit) The following is Javascript code
//Global object to store the cache
cache = {};
function makeRequest(requested_data){
request_hash = hash(requested_data);
if (cache[request_hash]){
handleData(cache[request_hash]);
}
else{
//Make Ajax call, get data response back and store it in the cache
request_hash = hash(requested_data);
cache[request_hash] = data;
handleData(data);
}
}
Note: for hash()
, you can use any hashing algorithm out there, you don't really need a cryptography-level hash, just something to create a basic signature. I use the Javascript implementation of Java's hashCode()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.