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

329
Views
How i can fix 400 (Bad Request) ajax error on.change form jquery?

Hello guys I have a problem when I'm trying to send data by ajax and it's said that I have 400 (Bad Request) ajax errors and this is my code:

This is Html code: the rows is data of my database $row['attributes'] it has (size,brand,color......)

 <form id="form">
    <?php foreach($rows as $row): ?>
    <fieldset>
        <?php
          $result_attributes = get_terms([
            'taxonomy' => $row['attributes'],
            'hide_empty' => false,
          ]);
        ?>
        <select id="select-wid" name="<?php echo $row['attributes']?>">
          <option value="">Select</option>
            <?php foreach($result_attributes as $result_attribute) : ?>
                <option value="<?php echo $result_attribute->term_id; ?>"><?php echo $result_attribute->name; ?>
                </option>
            <?php endforeach; ?>
        </select>
    </fieldset>
    <?php endforeach;
This is jquery code:
(function($){
                $(document).ready(function(){
                  $(document).on('change', '#form', function(e) {           

                    var data = $(this).serialize();

                    e.preventDefault();

                    console.log(data);
                    $.ajax({
                      url: my_url,
                      data: data,
                      action: 'myactionfunction',
                      type: 'post',
                      success: function(result) {
                        $('.products').html(result);
                      },
                      error: function(result) {
                        console.warn(result)
                      },
                    });

                  });
                });
})(jQuery);

Image from console enter image description here

Image from php enter image description here

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!