E
E
Eugene2018-09-03 13:45:41
Yii
Eugene, 2018-09-03 13:45:41

For the life of me, I can’t find the error, where did she hide?

I send the ID to the server with Ajax, I output the result to the console.
In the controller

public function actionAdd()
    {
        if (Yii::$app->request->isAjax && Yii::$app->request->isGet)
        {
            $id = Yii::$app->request->get('id');
            $product = Notebooks::findOne($id);
            if(empty($product))
            {
                return false;
            }
            else
            {
                $session = Yii::$app->session;
                $session->open();
                $compare = new Compare();
                $compare->addToCompare($product);

            }

        }

    }

Compare Model
namespace app\models;

use yii\db\ActiveRecord;


class Compare extends ActiveRecord
{
    public function addToCompare($product, $qty = 1)
    {
        return 'работайпсина';
    }
}

And though you kill the word rabotaypsina it does not return. But if I write It will send the word + Three-story error. I read that in Yii2 now you can only use Return. Why doesn't the return work?
echo 'работайпсина';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2018-09-03
@evgen9586

Add a return here:
$compare->addToCompare($product);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question