add information to input when AJAX returns null

When I submit a form via AJAX and it returns null, I want to append a text message below the original input box, and when I resubmit with a valid value(which means the AJAX call returns what I want), delete this message.

How can I do this? Thank you so much!!

I tried something like this in my AJAX call:

success: function(data){
      if(data.Status === "SUCCESS"){
                //deal with the data
                //NOT SURE WHAT TO DO HERE

Answers 1

  • I think you can delete msg in "SUCCESS", add msg delete it in else case. Add function: append() appendTo() insertAfter() delete function: remove() empty() You can select it in you case.

Related Articles