Answer the question
In order to leave comments, you need to log in
How to disable caching in angular?
The json file is read and displayed as a table, when the json object is deleted, the list is not updated, although the variable in which json is updated. The list will be updated only if you open this json in the browser and press ctrl+f5.
Uninstall code below
deleteApp(app: any) {
let agree = confirm(`Вы уверены что хотите удалить ${app.code}?`);
if(agree){
this.body = new HttpParams({
fromObject: Object.assign(app, {action: 'delete'})
})
this.http.post('assets/editAppList.php', this.body, {responseType: 'text'}).subscribe(
(response) => {
console.log('всё хорошо');
this.appList = JSON.parse(response)
},
(error) => {
console.error(error);
}
);
}
}
$app_json = 'http://logist/assets/applications.json';
$app_list = json_decode(file_get_contents($app_json));
for($a=0; $a<count($app_list); $a++){
if($app_list[$a]->code==$_POST["code"]){
array_splice($app_list, $a, 1);
}
}
print_r($app_list);
file_put_contents("applications.json", json_encode($app_list));
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question