how can I know if submit post method was success in html

I have a form in html with a post method
I need to know when the response to the post request
how can I catch it?

<form action='MyUrl' method="post" onsubmit="sub()">
     <input type="text" name="fname" required oninvalid="this.setCustomValidity('first name is required')"
                oninput="this.setCustomValidity('')">
     <button type="submit" name = "submit" value = "Submit">send</button>
</form>