php – Look at this sample code to send data via ajax

I want to clear errors which occur, when the user put unacceptable data, the following code working well, but the problem is when user fill acceptable data the success message is undefined because i didn’t define anything after the action,
How can ic clear the error message when user fill the input again.

I mean,

My code work well when user send an acceptable data, and it show success message, and when user send unacceptable data the form return an error specified on the server side, but when user repeat to write an acceptable and submit the form, it return message “undefined”

I don’t want this message, i want the message to dissappear

   //...after clicking  button 
   //define my data  
           url: 'url.php',
           type: 'POST',
           data: mydata,
           dataType: "JSON"
        }).done( function (data) {
         if (data.success == true) {
         } else {
      //code continue....