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

224
Views
submitting form data on jquery button click

I have a button by where onclick i am trying to send the form data to the server page to process. but somehow the formdata is going empty

can anyone guide what i am doing wrong here, here is my code

function ajax(obj) {
    alert('hello');
    console.log(obj);
    var form = document.querySelector('form');
    var data = new FormData(form);
    var post_url = $('#formid').attr("action"); //get form action url
    var form_data = $('#formid').serialize() & '&yes=1'; //Encode form elements for submission 
    console.log(form_data);
    console.log(data);
    $.post(post_url, form_data, function( response ) {
        $("#results").html(response);
    });
    return false;
}

the function ajax is called on the button click inside a form

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using post menthod wich gets params in body serilliazing the args like that is good for GET request you should send in body just use a object holding all the info

$.ajax({
  type: "POST",
  url: url,
  data: data ,// object
  success: success,
  dataType: dataType
});
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!