Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pjax causes POST error #24

Open
dartunian opened this issue Feb 9, 2020 · 6 comments
Open

Pjax causes POST error #24

dartunian opened this issue Feb 9, 2020 · 6 comments

Comments

@dartunian
Copy link

dartunian commented Feb 9, 2020

For some reason, whenever I load Pjax (or make ajax requests) on any page, POST requests get sent to /noty/default/index as well.

https://imgur.com/j0RQP2c

Not the greatest with JS, so a little bit confused what's going on here, any insight would be appreciated.

edit: to clarify, everything seems to work fine, i'm just unsure why these requests are being sent

@loveorigami
Copy link
Owner

loveorigami commented Feb 9, 2020

Because every layer write message in flash

Yii::$app->session->setFlash('error',   'ajax error');

and after every ajax call notification-wrapper read this message from session once after POST request and display it in your layer (noty, toaster, etc..).
Here https://github.com/loveorigami/yii2-notification-wrapper/blob/master/src/Wrapper.php#L170

If your dont send POST after ajax - you can see here
https://github.com/loveorigami/yii2-notification-wrapper#disable-shownoty-after-ajax-calls

@dartunian
Copy link
Author

dartunian commented Feb 11, 2020

I have been using this on all my pjax requests (and ajax), ie
Pjax::begin(['id' => 'lib_js', 'clientOptions' => ['showNoty' => false]]);
but still the problem persists
https://i.imgur.com/axcF3hu.png

@loveorigami
Copy link
Owner

You have 500 error in noty/default/index (not found router?).

Please, check your config as in Readme, clear cache, etc...

@dartunian
Copy link
Author

dartunian commented Feb 12, 2020

Okay, I did find that removing the 'template' option from my widget setup fixed the 500 error.
Still unsure why this would be throwing 500 error.

'toast' => [
    'fade' => 'slow',
    'template' => '<div class="alert alert-%priority% alert-dismissible" role="alert">' .
                    '<button type="button" class="close" data-dismiss="alert">' .
                        '<span aria-hidden="true">&times;</span>' .
                        '<span class="sr-only">Close</span>' .
                    '</button>' .
                    '<span class="message"></span>' .
                '</div>',
],

Further, though, I don't understand why 2 requests to /noty/default/index are being sent per Pjax call.

@loveorigami
Copy link
Owner

loveorigami commented Feb 12, 2020

May be you have grid view or submit form via ajax?
Debug panel is enabled? If yes - disable it and see result in chrome console...

@dartunian
Copy link
Author

Yes, I do use gridview, still unsure why the template option would be affecting routing. I'm not sure what you're suggesting, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants