X
X
xFreake2016-12-28 15:15:09
Yii
xFreake, 2016-12-28 15:15:09

Why is Ajax not working in yii2?

there is a code that should transfer the data to a file in the same folder

$('.delete').click(function () {

        var qty = $(this).parent();
        var chi = $(qty).children();
        var chi1 = $(chi).children();
        var src = $(chi1).attr("src");
        console.log(src);

        $.ajax({
            url: "delete_img.php",
            type: "POST",

            data: {
                src : src
            },
            success: function(response){

            console.log(response);
            }
        });
    });

But it doesn't work, please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-12-28
@slo_nik

Good afternoon.
What exactly doesn't work?
Explain in more detail.
So far, I can say that most likely you have a problem here:
You do not need to specify the file name with the extension, but the route to the controller and action.
Something like this:
You may need to use helpers Url::to() or Url::toRoute().
ps The route also depends on the UrlManager settings in the configuration file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question