PHP code example of loveorigami / yii2-ajaxq
1. Go to this page and download the library: Download loveorigami/yii2-ajaxq library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
loveorigami / yii2-ajaxq example snippets
use lo\widgets\Ajaxq;
echo Ajaxq::widget([
'url' => '/site/demo',
// 'success' =>'$(".res").html(res)',
// 'tpl' => 'from_to' // default view for generating ajax requests
]);
/**
* Controller name - Site
* Demo for ajaxq request
* @return json
*/
public function actionDemo()
{
$post = \Yii::$app->request->post('dataq'); // get associative array dataq
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$data['id'] = $post['id'];
$data['mes'] = $post['id'].' - It is ok!';
$res = print_r($data, true);
echo json_encode($res);
}
php composer.phar