A
A
AlexAll2019-02-18 09:20:39
Yii
AlexAll, 2019-02-18 09:20:39

Why does yii2 on js ajax request give a minus status?

I do image deletion via ajax on js
Here is the function itself

function  deletImage(id){
    var request = new XMLHttpRequest();
    request.open('POST','/item/delete-image?id='+id,true);
  };

When you click on the link that calls this function, nothing is deleted, but what the Debugger gives out (I clicked delete six times)
5c6a4f040747f382142186.png
And if you just enter this link in the browser /item/delete-image?id=id, the deletion works.
What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2019-02-18
@orlov0562

Try to debug manually: open the controller and put die('123') there, at the beginning, on the trail. line, etc.. You will find a place where everything stalls, or you will find that nothing is simply returned from the controller (response I mean)
Because in the browser you have a GET request, and you send a POST

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question