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

177
Views
JS AJAX for passing checkbox values into DB

I am working on ajax code for passing text values into DB.

Now I have improved my form with a pair of checkboxes (chk1, chk2).

How to adapt them into my ajax code?

$(function() {
    $('#register').click(function(e) {
        var valid = this.form.checkValidity();

        if (valid) {
            var var1 = $('#var1').val();
            var var2 = $('#var2').val();
            var var3 = $('#var3').val();
            var var4 = $('#var4').val();

            e.preventDefault();

            $.ajax({
                type: 'POST',
                url: 'process.php',
                data: { var1: var1, var2: var2, var3: var3, var4: var4 },

                success: function(data) {
                    if (data !== 'error') {
                        Swal.fire({
                            title: 'Success',
                            type: 'success',
                        });
                    } else {
                        Swal.fire({
                            title: 'Error',
                            type: 'error',
                        });
                    }
                },
            });
        } else {
        }
    });
});
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!