Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49107

Show error if empty

$
0
0

@khalilben wrote:

Hi,

Hi to show an error and don’t POST if there is no data ??

  declarerSinistre(){
    //http://michael.laffargue.fr/blog/2016/04/17/angularjs2-send-http-post-request-with-parameters-to-php/
    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    this.getData();

    var params = 'ClientId='+this.data.id+'&NomConducteur='+this.userData.NomConducteur+'&TelConducteur='+this.userData.TelConducteur+'&CinConducteur='+this.userData.CinConducteur+'&latitude='+this.la+'&longitude='+this.lo;
    this.http.post(this.apiSinistre, params , {headers: headers})
      .subscribe(
        data => this.afficherAlert('Réussite','Sinistre Déclaré'),
        err => this.afficherAlert('Erreur','Sinistre Non Déclaré')
      );
  }

Because it doesn’t work with this code, it send an undefined value

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>