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

453
Views
How can I force to work ajax form, method POST

Could you, please, help me with one task. I need to make a ajax request for several forms. But I have always gotten an error 405

jquery.min.js:4 POST http://127.0.0.1:5500/formx.php 405 (Method Not Allowed)

 <form method="post" class="x_order_form validate">                     
   <input value="" name="client" placeholder="Your name" required="" type="text" class="-metrika-nokeys">
   <input value="" name="tel" id="phone" placeholder="Your phone number" required="" type="text" class="-metrika-nokeys">
   <input value="" name="address" placeholder="Your address" required="" type="text" class="-metrika-nokeys">
   <button>ORDER NOW</button>                      
</form>

JS

$(document).ready(function() {
    $('form').submit(function (event) {
        event.preventDefault();
        var form = $(this);
        $.ajax({
            url: 'formx.php',
            type: 'POST',
            dataType: "html",
            data: form.serialize(),
            success: function(response) {
                alert("success");
            },
            error: function(response) {
                alert("failure");
            }
        });
        return false;
    })
});

PHP

<?php
if (isset($_POST["client"]) && isset($_POST["tel"]) && isset($_POST["address"])) { 

    $result = array(
        'client' => $_POST["client"],
        'tel' => $_POST["tel"],
        'address' => $_POST["address"]
    ); 

    echo json_encode($result); 
}
about 4 years ago · Juan Pablo Isaza
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!