M
M
Maxim Timofeev2015-08-25 18:56:58
JavaScript
Maxim Timofeev, 2015-08-25 18:56:58

How to run pjax from js?

I am using PJAX widget for YII2

<?php Pjax::begin(['id'=>'pjax-content', 'timeout' => 10000,'linkSelector'=>'.order']); ?>

But you need to update not only by clicking on the links, but also call the update from js when, for example , I tried to shove
$('#sorting').on('change',function(){
$.get(href, function(){
            $.pjax.reload({container:'#pjax-content' });
        });

but at the same time there are a lot of requests, including the usual get.

How to send an ajax request and then update the content with pjax?.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2015-08-26
@webinar

It works for me like this. This is a handler for the select change event in the form.

$.pjax.reload(this._container, {
        history: false,
        type: 'POST',
        data: form.serialize(),
        url: form.attr('action')
      });

OK. mark)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question