如何更新Web Profiler工具栏以显示有关Ajax请求的数据 [英] How to update the web profiler toolbar to show data about an ajax request
问题描述
我目前正在构建一个完全支持ajax页面加载的应用程序.初始页面加载后,浏览网站只会加载内容,而不会加载标题或菜单.
I am currently building an app that fully supports ajax page load. After an initial page load, navigating through the website only loads the content and not the header or the menu.
整个应用程序运行良好,但是我想刷新Web事件探查器工具栏以显示最后的ajax请求信息.
The whole app is working great but I would like to refresh the web profiler tool bar to show the last ajax request information.
我从响应标头中获得了xdebug令牌,并且我试图扩展javascript部分以替换工具栏的当前内容,但是我还没有成功.
I got the xdebug token from the response header and I am trying to extend the javascript part to replace the current content of toolbar but I haven't been successful yet.
我该怎么做?有什么我应该注意的事情吗?
How can I accomplish this? Is there anything specific I should be aware of?
推荐答案
我最终对对象Sfjs
的load
方法进行了反向工程",结果证明它的工作相当不错.
I ultimately "reverse-engineered" the load
method of the object Sfjs
and turns out it's working pretty nicely.
这是解决方案
// Query the proper URL
$.get('/my-url', function (data, status, xhr) {
// Get the xdebugToken from response headers
var xdebugToken = xhr.getResponseHeader('X-Debug-Token');
// If the Sfjs object exists
if (typeof Sfjs !== "undefined") {
// Grab the toolbar element
var currentElement = $('.sf-toolbar')[0];
// Load the data of the given xdebug token into the current toolbar wrapper
Sfjs.load(currentElement.id, '/_wdt/'+ xdebugToken);
}
})
这篇关于如何更新Web Profiler工具栏以显示有关Ajax请求的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!