Body: <p>I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code.</p>
  
  <p><strong>My form is as below:-</strong>   </p>
  
  <pre><code>&lt;form method="post" action="" accept-charset="UTF-8" class="basic-form" id="contactForm"&gt;
         {{ csrfInput() }}
         &lt;input type="hidden" name="action" value="contact-form/send"&gt;
         &lt;div class="form-group"&gt;
                &lt;input type="text" class="text-field" id="text-630573652" name="firstName" value="" required="" placeholder="Name *" autocomplete="off"&gt;
         &lt;/div&gt;
        &lt;div class="layout-sm-12"&gt;
               &lt;button type="submit" class="btn white-btn-outline submit-btn"&gt;LET'S TALK&lt;i class="icon-long-arrow-bold-right"&gt;&lt;/i&gt;&lt;/button&gt;
                      &lt;/div&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p><strong>My ajax script is as follows:-</strong></p>
  
  <pre><code>$(function () {
          $('#contactForm').on('submit', function (e) {
          e.preventDefault();
          $.ajax({
              type: 'post',
              url: '/',
              data: $('#contactForm').serialize(),
              dataType: 'json',
              success: function (response) {
                   alert(response);
              }
          });
  
          });
  });
  </code></pre>
  
  <p>For this I am getting error in console like 404 page not found. How to redirect to send controller index function using ajax request. As per other tutorials '/' is not working here.</p>
  
  <p>Anyone please help...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-07T19:02:13.600Z
Comments.Text: If you read the docs: The only required fields are fromEmail and message. Everything else is optional. You have neither.
Comments.UserDisplayName: Christopher Dosin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-08T04:14:18.960Z
Comments.Text: Thank you for the reply. I am asking for how we will redirect to controller url using ajax
Comments.UserDisplayName: Rakhi Vijayan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-11T16:52:43.877Z
Comments.Text: Since you have **contact-form/send** as your hidden field for form action, have you tried using this for the AJAX url?
Comments.UserDisplayName: 4midori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-11T17:11:28.543Z
Comments.Text: Thank you. That works.
Comments.UserDisplayName: Rakhi Vijayan
Tags: <plugin-development><craft3><php><ajax><plugin-contactform>
Title: Contact form plugin ajax submit URL not working
ThreadText: # Contact form plugin ajax submit URL not working
  
  (Asked by: username_0 on 2019-11-07)
  
  I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code.
  
  **My form is as below:-**
  
  ```
  <form method="post" action="" accept-charset="UTF-8" class="basic-form" id="contactForm">
         {{ csrfInput() }}
         <input type="hidden" name="action" value="contact-form/send">
         <div class="form-group">
                <input type="text" class="text-field" id="text-630573652" name="firstName" value="" required="" placeholder="Name *" autocomplete="off">
         </div>
        <div class="layout-sm-12">
               <button type="submit" class="btn white-btn-outline submit-btn">LET'S TALK<i class="icon-long-arrow-bold-right"></i></button>
                      </div>
              </form>
  
  ```
  
  **My ajax script is as follows:-**
  
  ```
  $(function () {
          $('#contactForm').on('submit', function (e) {
          e.preventDefault();
          $.ajax({
              type: 'post',
              url: '/',
              data: $('#contactForm').serialize(),
              dataType: 'json',
              success: function (response) {
                   alert(response);
              }
          });
  
          });
  });
  
  ```
  
  For this I am getting error in console like 404 page not found. How to redirect to send controller index function using ajax request. As per other tutorials '/' is not working here.
  
  Anyone please help...
  
  **Tags:** plugin-development, craft3, php, ajax, plugin-contactform
  
  > **Comments:**
  > **username_1**: If you read the docs: The only required fields are fromEmail and message. Everything else is optional. You have neither.  
  > **username_0**: Thank you for the reply. I am asking for how we will redirect to controller url using ajax  
  > **username_2**: Since you have **contact-form/send** as your hidden field for form action, have you tried using this for the AJAX url?  
  > **username_0**: Thank you. That works.  
  
  ---
  
  ## 0 answers
  
  