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

400
Views
Error de referencia no capturado: deleteNote no está definido en HTMLButtonElement.onclick

entonces, acabo de aprender a hacer un sitio web con matraz. todo estaba bien hasta que este error me vuelve loco. ¿puedes resolver mi problema?

esta es mi función def para eliminar alguna nota

 @views.route('/delete-note',methods=['POST']) def delete_note(): note = json.loads(request.data) noteId = note['noteId'] note = Note.query.get(noteId) if note: if note.user_id == current_user.id: db.session.delete(noteId) db.session.commit() return jsonify({})

y este es mi codigo .js

 function deleteNote(noteId) { fetch("/delete-note", { method: "POST", body: JSON.stringify({ noteId: noteId }), }).then((_res) => { window.location.href = "/"; }); }

y así es como hago el botón con html

 <ul class="list-group list-group-flush" id="notes"> {% for note in user.notes %} <li class="list-group-item"> {{ note.data }} <button type="button" class="close" onClick="deleteNote({{ note.id }})"> <span aria-hidden="true">&times;</span> </button> </li> {% endfor %} </ul>

¿Puedes ayudarme? no se como solucionarlo por favor, ayúdame

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

0

¿Estás cargando el archivo js correctamente? Puede intentar cargar la función antes del marcado HTML, por ejemplo

 <head> <script> function deleteNote(noteId) { fetch("/delete-note", { method: "POST", body: JSON.stringify({ noteId: noteId }), }).then((_res) => { window.location.href = "/"; }); }</script> </head> <body> <ul class="list-group list-group-flush" id="notes"> {% for note in user.notes %} <li class="list-group-item"> {{ note.data }} <button type="button" class="close" onClick="deleteNote({{ note.id }})"> <span aria-hidden="true">&times;</span> </button> </li> {% endfor %} </ul> </body>
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!