Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Submitting ajax form

I need to submit this form for it to work. Here is my code, but it doesn't want to work. The request must be sent using this link, for example, https://www.eymedic.form.php. How do I get it to work fine?

<form method="POST" id="form" action="#" class="form">     
      <div class="field">
        <label for="input-kitId" class="label is-size-7 has-text-weight-light has-text-left">Order ID</label>
        <div class="field"><div class="control is-expanded">
          <input type="number" id="input-kitId" class="home-form__input input is-danger" name="number" value="" placeholder="Order ID">
          </div>
        </div>
      </div>
      
      <div class="field">
        <label for="input-firstName" class="label is-size-7 has-text-weight-light has-text-left">Email</label>
        <div class="field"><div class="control is-expanded">
          <input type="email" id="input-firstName" class="home-form__input input" name="email" value="" placeholder="Email">
          </div>
        </div>
      </div>
      
      <button type="submit" class="button is-midnightBlue">Generate Booking Reference</button>
    </form>
    
    
  </div>
</div>
    
   
<script>
  
$( "submit" ).click(function() {
      if(form.val()) {
            var msg = $("#form").serialize();
            $.ajax({
              type: 'POST',
              url: 'https://www.harleymedic.co.uk/qrcodes/form.php',
              data: msg,
              success: function(data) {
                console.log(data);
                if (data.status === 'OK') {window.location.href='second_page.html'}
                else {alert(data.message)};
              }
            });
        };
    });
  
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You don't have submit element, use form element instead and submit action should be prevented.

$( "form" ).click(function(e) {
  e.preventDefault()
  var msg = $("#form").serialize();
  $.ajax({
    type: 'POST',
    url: 'https://www.harleymedic.co.uk/qrcodes/form.php',
    data: msg,
    success: function(data) {
      console.log(data);
      if (data.status === 'OK') {window.location.href='second_page.html'}
      else {alert(data.message)};
    }
  });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!