Download the PHP package smallbearsoft/yii2-ajax without Composer
On this page you can find all versions of the php package smallbearsoft/yii2-ajax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smallbearsoft/yii2-ajax
More information about smallbearsoft/yii2-ajax
Files in smallbearsoft/yii2-ajax
Package yii2-ajax
Short Description This is a ajax widget of yii2 which will generate a div. The link click or form submission (for those link and form with data-ajax attribute) in this div will trigger an AJAX request.
License MIT
Informations about the package yii2-ajax
yii2-ajax
This is a ajax widget of yii2 which will generate a div. The tags (except form) click or forms submission (for those tags and forms with data-ajax attribute) in this div will trigger an ajax request.
Simple example for link
We can get some data by ajax link useing Ajax widget. First, we should have a controller and an action to render our view. Of course, we can just use SiteController as our controller. Then we write an action in SiteController named actionLink to render link.php. In addition, add actionResponse action to response ajax request through ajax link:
SiteController.php
link.php
Simple example for form
If you want to use ajax to post a form to server, you can use this Ajax widget make it essay. We will still use SiteController as our controller. Then we add two actions actionForm and actionPost. To make it simple, we will not use ActiveForm widget, but you can use that in your code:
SiteController.php
form.php
Actually you can also use Ajax widget to upload files, just add an input like <input type="file" name="image"/>. You will see your file in $_FILES variable on server.
More tutorials
See Home wiki for more tutorials.
Tips
To trigger the Ajax widget, you can use a submit button or a jquery submit() function. But cannot use the pure javascript submit() function to trigger it. You can use:
Cannot use:
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json file.