DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simulate XHRs With Wget

06.05.2010
| 6610 views |
  • submit to reddit
        To test AJAX calls when developing a webapp, XHRs can be simulated by wget:

wget --header="X-Requested-With: XMLHttpRequest" <your-url-here>

wget saves the request to a file by default. To print to the command line: 
wget --header="X-Requested-With: XMLHttpRequest" -qO- <your-url-here>

<a href="http://groups.google.com/group/tipfy/browse_thread/thread/520e7726eaf7dd6f">Google Groups reference</a>
<a href="http://www.commandlinefu.com/commands/view/1913/redirect-wget-output-to-the-terminal-instead-of-a-file">wget reference</a>