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

334
Vistas
Ajax delete request returns 200 but fires error

I am trying to create a simple API for my project. I am sending a DELETE request using jquery Ajax. The Delete request gets sent, does what it is supposed to do(deletes an entry from the database), return a status 200, but fires an error event.

I have already looked for solutions on these posts but they haven't been able to help me:

Ajax request returns 200 but error event is fired Ajax request returns 200 OK but error event is fired Ajax delete returns 200 but firing off error event

This is the AJAX code:

        function ajaxCall(method,hmm){ // function that send an ajax request
            $.ajax({
                dataType: 'JSON',
                url: '/APIHandler.php?' + $.param({values:hmm}),
                type: method,
                success: function(response) { // when the request is done delete the previously placed products for new ones
                    console.log(response);
                    const parentDiv = document.querySelector('#basic-grid');
                    removeAllChildNodes(parentDiv);
                    turnToObjects(response);
                },
                error: function(xhr){
                    alert(xhr);
                    console.log(xhr);
                }
              });
        }
...
ajaxCall('DELETE',checked);

The APIHandler code:

if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
    $vals = $_GET['values'];
    $API->delete($vals);
}

The request response:

abort: ƒ (e)
arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.r (<anonymous>:1:83)]
caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.r (<anonymous>:1:83)]
length: 1
name: "abort"
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: jquery.min.js:2
[[Scopes]]: Scopes[3]
always: ƒ ()
catch: ƒ (e)
done: ƒ ()
fail: ƒ ()
getAllResponseHeaders: ƒ ()
getResponseHeader: ƒ (e)
overrideMimeType: ƒ (e)
pipe: ƒ ()
progress: ƒ ()
promise: ƒ (e)
readyState: 4
responseText: ""
setRequestHeader: ƒ (e,t)
state: ƒ ()
status: 200
statusCode: ƒ (e)
statusText: "OK"
then: ƒ (t,n,r)

I also can't find any solutions for the error

[Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.r (<anonymous>:1:83)]
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Add contentType:'application/json' to your code

And change dataType to text

...
dataType: 'text',
contentType:'application/json'
...
over 4 years ago · Santiago Trujillo Denunciar

0

You set your dataType as JSON so $.ajax is attempting to parse your ajax response as JSON but your response is empty so an error is thrown.
Either send a JSON response from your request or remove the dataType parameter.

over 4 years ago · Santiago Trujillo 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