• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

210
Views
Usando ajax para convertir entradas en JSON y POST a api

Tengo problemas para entender cómo se puede convertir la entrada de la etiqueta en JSON y luego publicarla en mi API.

Mi código de interfaz es

 <div> <form className="AddMentor"> <table> <tr> <td> <label>MentorID<input type="text" name="MentorID" /></label> </td> <td> <label>MentorName<input type="text" name="MentorNAME" /></label> </td> <td> <label>MentorEMAIL<input type="text" name="MentorEMAIL" /></label> </td> <td> <label>MentorPH<input type="text" name="MentorPH" /></label> </td> <td> <label>MentorLINKEDIN<input type="text" name="MentorLINKEDIN" /></label></td> <td> <label>MentorPM<input type="text" name="MentorPM" /> </label> </td> </tr> </table> <button type="submit" id="save">Add Mentor</button> </form> </div>

Y MI código api es

 //ADD MENTOR API router.route('/MentorEle').post((request,response)=>{ let Mentor = {...request.body} dboperations.addMentor(Mentor).then(result => { response.json(result); }) })

Intenté esto para convertirlo en JSON y PUBLICAR en mi api

 $(document).on('click', '#save', function(event) { event.preventDefault(); var data = $('tr').map(function() { var obj = {}; $(this).find('input, select').each(function() { obj[this.name] = $(this).val(); }); return obj; }).get(); console.log(JSON.stringify(data)); });

Desafortunadamente, no funcionó, enfrenté varios errores y el error actual es

Módulo no encontrado: Error: No se puede encontrar el archivo: 'node-jquery.js' no coincide con el nombre correspondiente en el disco: '.\node_modules\jquery\lib\jQuery'.

por favor, alguien que me ayude con este código o el enfoque ajax de él

over 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error