Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda