我是yii2的初学者,并尝试使用搜索按钮上的Pjax搜索Gridview中的字段.我用GET方法做了这个,但我想用POST方法做到这一点.那我怎么能用Yii2 Pjax(post方法)和分页来做到这一点?
这是我的代码:
_details.php:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use kartik\depdrop\DepDrop;
$js = <<<JS
// get the form id and set the event
$('#bank-details-form').on('beforeSubmit', function(e) {
var form = $(this);
if(form.find('.has-error').length) {
return false;
}
$.ajax({
url: form.attr('action'),
type: 'post',
data: form.serialize(),
success: function(response) {
var txtValue = $("#bankdetails-bank_name").val();
if(txtValue == "")
{
alert("Please select bank name");
return false;
}
var bank_name = $('#bankdetails-bank_name option:selected').text();
var state = $('#bankdetails-state option:selected').text();
var district = $('#bankdetails-district option:selected').text();
var city …Run Code Online (Sandbox Code Playgroud)