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

107
Views
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 answers
Answer question

0

Add contentType:'application/json' to your code

And change dataType to text

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

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 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!