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

How to handle ajax actions? #18

Open
Koc opened this issue Jun 25, 2017 · 8 comments
Open

How to handle ajax actions? #18

Koc opened this issue Jun 25, 2017 · 8 comments

Comments

@Koc
Copy link

Koc commented Jun 25, 2017

For example we have some ajax action which return json/xml. How it possible to profile it?

@Koc Koc changed the title How to handle ajax actions How to handle ajax actions? Jun 25, 2017
@phoenix128
Copy link
Contributor

We are investigating on it to find a good way to debug it. Do you have any suggestion about that?

@Koc
Copy link
Author

Koc commented Jun 25, 2017

Maybe using Symfony's approach: write serialized data + csv index with possibility show info about last N requests. Plus overwrite xmlhttprequest http://symfony.com/blog/new-in-symfony-2-6-ajax-requests-in-the-web-debug-toolbar

@Koc
Copy link
Author

Koc commented Jun 25, 2017

see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php for more info

@phoenix128
Copy link
Contributor

Could be an option. Thank you for your suggestion. We are also investigating in using payloads inside the response headers.

@Koc
Copy link
Author

Koc commented Jun 25, 2017

Please do not make response headers too big, it may cause hard to debug errors on webserver/browser side. See Seldaek/monolog#172

@phoenix128
Copy link
Contributor

phoenix128 commented Jun 25, 2017

That was exactly our concern! This is why we stopped it for a while, but your suggestion could be a better option.

@barryvdh
Copy link

In https://github.com/maximebf/php-debugbar we use different approaches:

  • For regular requests, render the data in json on the page itself
  • For ajax requests, send a request ID in the headers. This ID is used to make an ajax request to the API to get the data (to prevent too large headers)
  • For redirects (post actions), store the data in the session.

It then provides a dropdown to switch between requests. Eg. a save action will have 2 items, the POST request and the redirected page. So you can always see what happened on the POST (which is mostly more interesting). And ajax requests will trigger a new item in the dropdown.

@phoenix128
Copy link
Contributor

@barryvdh , seems a good approach.

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

No branches or pull requests

3 participants