Success callback

A callback function invoked if the request succeeds. The function gets passed one argument: the data returned from the server.

$("form").async({
  success: function(response) {
    // Your code here
  }
});

Example

Change the class name if the response variable egals to sucess.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Success callback demo</title>
  <link rel="stylesheet" href="http://127.0.0.1:4000/assets/css/demo.css">
</head>
<body>
  <form action="/" method="post">
    <input name="xs_username" placeholder="Username">
  </form>

  <script src="https://code.jquery.com/jquery-3.4.0.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/form-async/dist/form-async.min.js"></script>
  <script>
     $("form").async({
        success: function(response) {
          if (response == "success") {
            $(this).addClass("success");
          }
        }
     });
  </script>
<body>
</html>

Demo: