Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

0

Add contentType:'application/json' to your code

And change dataType to text

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

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda