Vanilla JS ajax post not triggering Tracy bar

Notice: This thread is very old.
tpr
Member | 55
+
0
-

Hi,

I spent some time figuring out why Tracy ajax bar doesn't show up when using pure vanilla JavaScript instead jQuery when doing an ajax post.

I've set ‘X-Requested-With’ to ‘XMLHttpRequest’ (otherwise the entire post is not working)
The response does have ‘X-Tracy-Ajax’ so Tracy surely detects that this is an ajax call, but the bar is still not showing. However, if I substitute the js with jQuery ajax, it works fine.

Any clue on this? I can provide further details if you wish. Note that I'm using the standalone Tracy but I guess this doesn't make a difference.

Jan Tvrdík
Nette guru | 2595
+
0
-

I think you need to call either xhr.getResponseHeader() or xhr.getAllResponseHeaders()

tpr
Member | 55
+
0
-

Thanks, but no success. Perhaps there are other factors in my current environment that play role

tpr
Member | 55
+
0
-

It seems that the ajax debug bar isn't showing up if I set the header to this:

xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

Setting it to ‘application/json’ or simply omitting makes the bar appear.
I'm submitting a form so obviously json won't work.

Last edited by tpr (2016-07-18 15:46)

adrianbj
Member | 31
+
0
-

Does anyone have a working example of the AJAX bar being triggered by pure vanilla JS when the content type is application/x-www-form-urlencoded?

tpr
Member | 55
+
0
-

It seems that it's working fine here after the latest Tracy updates. Thanks all!

adrianbj
Member | 31
+
0
-

Everything is working great for me now also! Looks like it was this change:
https://github.com/…0b07c7795831 that made the difference. Credit goes to @tpr for figuring this out.

Last edited by adrianbj (2016-07-30 16:36)