How display successfully message in HTML file

Hi guys,
I use native http for post request
How display successfully message in HTML file And pop the window

Greetings,

You could use Toast or Alert component to display message.

I am new with ionic, so please can you give an example?

Post you code sample here so I could create one or you could just follow ionic documentation, it’s pretty easy.

View this examples Toast or Alert . It may help you.

hi this is my code:
sendPostRequest() {

this.resetError()

if (this.isDataValid()) {

this.http.sendRequest(‘myapi/createcomment’,

  {

    method: 'post',

    data: { id: this.id, Name: this.Name, EmailFrom: this.EmailFrom, text: this.text },

    headers: { Authorization: 'OAuth2: token' },

    timeout: 5000

    

  }

  

)

  .then(response => {

    

    // prints 200

    console.log(response.status);

       

  })

  .catch(response => {

    // prints 403

    console.log(response.status);



    // prints Permission denied

    console.log(response.error);

  });

 

}

}

This combination concerns me. Why aren’t you using Angular’s HttpClient?

import { ToastController } from '@ionic/angular'; // Added Line
constructor(public toastController: ToastController) {} // Add in constructor

sendPostRequest() {
this.resetError()
if (this.isDataValid()) {
this.http.sendRequest(‘myapi/createcomment’,
  {
    method: 'post',
    data: { id: this.id, Name: this.Name, EmailFrom: this.EmailFrom, text: this.text },
    headers: { Authorization: 'OAuth2: token' },
    timeout: 5000
  })

  .then(response => {
    // prints 200
    this.presentToast('Success Message') // call toast
    console.log(response.status);
  })
  .catch(response => {
    // prints 403
    this.presentToast('Error Message') //Call toast
    console.log(response.status);
    // prints Permission denied
    console.log(response.error);

  });

  async presentToast(msg) {
    const toast = await this.toastController.create({
      message: msg, //Custom Message
      duration: 2000 //Duration 
    });
    toast.present();
  }

}

Hope this will help.

To show a message that says something was successful, in an HTML file you can use an HTML element and make it look nice with CSS styling. Example:

Success Message

File uploaded successfully!

This will show the message in green on the webpage.

If you are dealing with email files like MSG and you want to convert them to HTML, you can use a tool like Softaken MSG to HTML Converter to get HTML files that look good and have the layout and content of the original email files, which is the email content and the email layout of the MSG files.