@sambhupal wrote:
Hi, I’m new in ionic 3,
- I can save sqlite data save to server database by using API (http).
- I have 4 data in my sqlite local storage.
- Following function: for each data is saved to server database successfully…
a) after success i got a response from server.
b) And according success message i run another function for delete single data(delete each data)
c) But what I am seeing only no. 4 data is delete other remain same.Here is my code:
synch(){
this.sqlite.create ({ name: “m_ilsapps.db”, location: “default” })
.then((db: SQLiteObject) => {
db.executeSql(“SELECT * FROM m_offline_pod_data ORDER BY m_offline_id ASC”, ).then((data) => {
if(data.rows.length > 0) {
for(var i = 0; i < data.rows.length; i++) {this.productInfo.m_offline_id = data.rows.item(i).m_offline_id; this.productInfo.m_pod_no = data.rows.item(i).m_pod_no;
this.http.post(“http://example.in/clix_mobile_apps/add-product-offline.php”,this.productInfo).subscribe( data => {
console.log( "SUCCESS => " + data);let offlineupdate = JSON.parse(data["_body"]);
if(offlineupdate.status == "success"){
this.MYdeleteData(this.productInfo.m_offline_id);
} else if(offlineupdate.status == "podnotmatch"){ this.toast.show("POD MISMATCH...try again...", '5000', 'center').subscribe( toast => { console.log(toast); } ); } }, err=>{ console.log("Error => "+ err); this.toast.show("NO SERVER RESPONSE...try again...", '5000', 'center').subscribe( toast => { console.log(toast); } ); }); } // for each end } console.log(this.products); }, (error) => { console.log("ERROR: " + JSON.stringify(error)); }); })
}
// delete function
MYdeleteData(myID){
alert(‘DELETE’+myID);
this.sqlite.create ({ name: “m_ilsapps.db”, location: “default” })
.then((db: SQLiteObject) => {
db.executeSql(“DELETE FROM m_offline_pod_data WHERE m_offline_id = '”+myID+"’", ).then((data) => {console.log(this.products); }, (error) => { //alert('delete error v3-10012') console.log("ERROR: " + JSON.stringify(error)); });
})
}Please help me
Posts: 1
Participants: 1