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

188
Vistas
How to make a post request using fetch rather than $.post

I am in the process of replacing ajax with fetch but have run into a problme when trying to execute a method.

Here is the orginal post request.

$.post('/cart/change.js', changes, ajaxify.onCartUpdated, 'json');

And here is the updated code. I dont get an error, but the method is not called.

let
  quantity = this.value,
  id = $(this).attr('id').replace('updates_', ''),
  changes = {
    quantity: quantity,
    id: id
},
fetch('/cart/change.js', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(changes)
})
.then(response => {
  return response.json();
})
.then(function() {
  return ajaxify.onCartUpdated;
})
.catch((error) => {
  console.error('Error:', error);
});
about 4 years ago · Juan Pablo Isaza
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