Yii2 Pjax not working

前端 未结 2 1767

I want to refresh the gridview using Pjax but somehow it is not working. Here is the code:

_search.php

    

        
2条回答
  •  醉梦人生
    2020-12-28 22:41

    The way Pjax is working is by sending another request with special headers. When pjax request is detected only html required to update container is returned from server. Line

    $.pjax.reload({container:\"#bank\"});
    

    will send another request, and inside actionIndex queryParams will be empty.

    You can solve this by storing search parameters to session or by specifing pjax url with parameters in query string.

    Try following:

      var url = urlWithFilters(); 
      $.pjax({url: url, container: '#bank'});
    

    In this case you don't need to create own ajax call, just create url with with filters.

提交回复
热议问题