P
P
Petr Fronin2016-08-01 00:56:20
Yii
Petr Fronin, 2016-08-01 00:56:20

How to access an action via ajax in yii2?

I do it like this:

$.ajax({
        url: 'http://mysite.ru/get-video',
        data: {url: url},
        success: function(data) {
              alert(data);
        }
    });

public function actionGetVideo()
    {
        $url = Yii::$app->request->get('url');
        echo $url;
    }

As a result, I get the following error:
XMLHttpRequest cannot load mysite.ru/get-video?url=. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' www.mysite.ru ' is therefore not allowed access.
There are no restrictions in behaviors.
If the link is simply inserted into the browser, then it works fine
. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-08-01
@qonand

the error says about problems with CORS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question