From WordPress form submit on-click event, how to call an external REST POST API?

  1. You donot need to edit or modify the wp-admin/admin-ajax.php as this is wp core file. If you want to use ajax you can check here

  2. For getting the values of form you can use serialize() function of jQuery.

  3. Please check the below code for calling REST API on click event.

     $('button').click(function(){
     $.ajax({
          type : "POST",
          dataType : "JSON",
          url : "/wp-json/v2/......",
          data : $(form#formID).serialize(),
          success: function(response) {
             alert(response);
          }
     }); 
    

    });

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)