i have this error : "ERROR SyntaxError: Unexpected token S in JSON at position 0 " in the provider function at ligne 4 ( at MapSubscriber.project) please i need your help!!
my update function that communicate with my php files
provider.ts
Update(dataOffres)
{
1 var url = 'http://www.opt.com/BACKEND/manage-location.php?
key=update&date_expiration='+dataOffres.date_expiration+
2 '&id_chef='+dataOffres.id_chef+'&id_vehicule=
'+dataOffres.id_vehicule+'&id_chauffeur='+dataOffres.id_chauffeur+
3 '&adresse='+dataOffres.adresse+'&id_offre='+dataOffres.id_offre;
4 var response = this.http.get(url).map(res => res.json());
5 return response;
}
the function that sends all the data required to the provider
test.ts
save(){
this.dataOffres.adresse =
this.formLocation.controls["adresse"].value;
this.dataOffres.date_expiration = this.formLocation.controls["date_expiration"].value;
this.dataOffres.id_vehicule = this.formLocation.controls["id_vehicule"].value;
this.dataOffres.id_chauffeur = this.formLocation.controls["id_chauffeur"].value;
this.dataOffres.id_chef=this.id;
this.dataOffres.id_offre=this.offre.id_offre;
this.presentLoading();
var check = moment(this.dataOffres.date_expiration ).isAfter();
if(check){
if(this.dataOffres.adresse!=this.offre.adresse||
(this.dataOffres.date_expiration!=this.offre.date_expiration)||
this.dataOffres.id_vehicule !=this.offre.id_vehicule||this.dataOffres.id_chauffeur
!=this.offre.id_chauffeur )
{
this.data.Update(this.dataOffres).subscribe(
data => {
if(data.result=="succees")
{
//this.hideForm = true;
this.loader.dismiss();
this.sendNotification(`l'offre avec ID : ${this.dataOffres.id_offre}
à été modifée avec succées!`);
this.navCtrl.popTo(OffresPage);
}
// Otherwise let 'em know anyway
else
{ this.loader.dismiss();
this.sendNotification('probleme serveur veuillez réssayer!');
}
});
} else{
this.loader.dismiss();
this.showPopup("Désolé","aucune champs a été modifé !!");
}
}else
{ this.loader.dismiss();
this.showPopup("Désolé","la date éxpiration n'est pas valide!!");}
}
finally the form
test.html
<form [formGroup]="formLocation" (ngSubmit)="save()">
<ion-row>
<ion-col inset>
<img src="assets/img/1.jpg" />
<ion-list inset>
<ion-item>
<ion-label color="appbase">Chauffeur</ion-label>
<ion-select [(ngModel)]="selectedChauffModel" formControlName="id_chauffeur">
<ion-option *ngFor="let item of chauffeurs" [value]="item.id_chauffeur">
{{item.nom_chauffeur}}
</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="!formLocation.controls.id_chauffeur.valid &&
formLocation.controls.id_chauffeur.dirty">
<p>Selectionnez un chauffeur</p>
</ion-item>
<ion-item>
<ion-label color="appbase">VĂ©hicule</ion-label>
<ion-select [(ngModel)]="selectedVehicModel" formControlName="id_vehicule">
<ion-option *ngFor="let item of vehicules" [value]="item.id_vehicule">
{{item.nom_vehicule}}
</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label color="appbase">Date</ion-label>
<ion-datetime displayFormat="YYYY-MM-DD" [(ngModel)]="datExpModel" (ionChange)="setDate(datExpModel)" formControlName="date_expiration"></ion-datetime>
</ion-item>
<!-- <ion-item *ngIf="formLocation.controls.date.">
<p>VĂ©rifiez la date Ă©xpiration</p>
</ion-item>-->
<ion-item>
<!-- <ion-icon name="mail" item-left></ion-icon>-->
<ion-label color="appbase">Adresse</ion-label>
<ion-input type="text" [(ngModel)]="adresseLocModel" formControlName="adresse"></ion-input>
</ion-item>
</ion-list>
</ion-col>
</ion-row>
<ion-row>
<ion-col class="location-col">
<button ion-button class="submit-btn" type="submit" [disabled]="!formLocation.valid">Valider</button>
</ion-col>
</ion-row>
</form>