I am a newcomer to Hybrid application development, currently utilizing Ionic Cordova for my project. My aim is to implement a POST method within the application.
var url = "http://XXXXXXXXXXXXX.com/XXXX";
var headers = new Headers();
headers.append("Accept",'application/json');
headers.append('Content-Type','application/json');
let options = new RequestOptions({headers : headers});
let postParams = {
Name: this.imagename,
StartDate: this.adstartdate,
EndDate: this.adEnddate,
UploadName:this.imagename
}
// The above code (postParams) seems to not be properly connected with the following code.
this.http.post(url,postParams,options)
.subscribe(data =>{
console.log(data['_body']);
alert('Success! Entered: '+ data['_body']);
this.jsonvalue = JSON.stringify(data['_body']);
alert('Json Value: '+ this.jsonvalue);
},error =>{
console.log(error);
alert('Fail');
}
I'm seeking guidance on where I may have faltered in this code. Please overlook any grammatical errors.