title: How to fix ajax request to the form handler file from the WordPress plugin. (I am developing a plugin myself)
body: <p>everyone!I'm creating WordPress plugin. The main goal of this plugin is creating form, and after user will fill out this form data from the form will be written to the database. I made the part of the plugin that is responsible for creating the database and displaying the form using a shortcode. But faced with a problem. How to send data from a form to a database using the ajax method.</p>
  <p>After activating the plugin, a table is created in the database:</p>
  <pre><code>if ( ! function_exists ( 'jal_install' ) ) {
  function jal_install (){
      global $wpdb;
      require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
      $table_name = $wpdb-&gt;prefix . &quot;liveshoutbox&quot;;
      $charset_collate = $wpdb-&gt;get_charset_collate();
          if($wpdb-&gt;get_var(&quot;SHOW TABLES LIKE '{$table_name}'&quot;) !== $table_name){
              $sql = &quot;CREATE TABLE $table_name (
              id mediumint(9) NOT NULL AUTO_INCREMENT,
  
              client_name tinytext NOT NULL,
              client_mail varchar(55) DEFAULT '' NOT NULL,
  
              PRIMARY KEY  (id)
              ) $charset_collate;&quot;;
          dbDelta( $sql );
      }   
    }
  }
  </code></pre>
  <p>The form on the page is displayed with a shortcode:</p>
  <pre><code>function form_shortcode() {
          ob_start(); ?&gt;
  
        &lt;form class=&quot;main_form&quot; method=&quot;POST&quot; action=&quot;&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;user_name&quot;&gt;
              &lt;input type=&quot;text&quot; name=&quot;user_mail&quot;&gt;
              &lt;button type=&quot;submit&quot;&gt;Subnit&lt;/button&gt;
        &lt;/form&gt;
        &lt;div class=&quot;main_form__success&quot;&gt;Greate Worck!&lt;/div&gt;
           
      &lt;?php 
        return ob_get_clean();
      }
  
      add_shortcode('form-shortcode', 'form_shortcode');
  </code></pre>
  <p>For adding data from the form to the database, there is a file: form_action.php I placed it in the main plugin directory. And for initiating the work of this file I use the form_ajax.js</p>
  <pre><code>$(&quot;form.main_form&quot;).submit(function() {
        var th = $(this);
        $.ajax({
          type: &quot;POST&quot;,
          url: &quot;/form_action.php&quot;,
        }).done(function() {
          $(th).find('.main_form__success').addClass('active').css('display', 'flex').hide().fadeIn();
          setTimeout(function() {
            $(th).find('.main_form__success').removeClass('active').fadeOut();
            th.trigger(&quot;reset&quot;);
          }, 3000);
        });
        return false;
      });
  </code></pre>
  <p>As a result, I cannot get to this form_action.php file. And I have an error. The code tries to find it in the root of the site, but not in the root of the plugin. I do not understand how to fix it, tell me how to do it please.</p>