1

When I am using xhprof profiling PHP code, it works fine. I reference the documentation written by Lorenzo Alberton, http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/.

But you know that we always have many Ajax calls in a web application. When I try to include header.php and footer.php in this article, how can I prevent it from destroying the Ajax call from the JavaScript client?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Leon
  • 2,810
  • 5
  • 21
  • 32

3 Answers3

1

I had the same exact issue. I fixed it by adding the following lines at the top of the Ajax responding script.

global $_xhprof;        
@$_xhprof['display'] = false;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
0

Have you tried to remove the "Profiler Output" link from your code ? xhprof shouldn't be changing anything since It's just a profiler.

You can try a if !is_ajax to hide it on ajax requests.

function is_ajax()
{
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
}
Roch
  • 21,741
  • 29
  • 77
  • 120
  • yes I just want to remove "Profiler Output", but how can I only remove it when the request is a ajax call? – Leon Feb 16 '11 at 15:12
  • I have updated my answer, I hope it will work with your code. – Roch Feb 16 '11 at 16:52
0

The best way to accomplish this is to program in the exception URLs in your config.php (https://github.com/preinheimer/xhprof/blob/master/xhprof_lib/config.sample.php)

The application will not display the footer link on those URLs (the feature was designed with this use case in mind).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
preinheimer
  • 3,712
  • 20
  • 34