Cloud Photo

Azure Data Architect | DBA

The Best XHR Script

XHR or XMLHttpRequest is arguably the cornerstone of the web 2.0 schlock and, honestly, I think it does add a great deal of value to a web application when you can execute requests and not lose your context. For example, given a list of 500+ comments to review and edit, it’s nice to be able to edit them in place rather than, edit, submit, and scroll to find where you left off.

That said, I use and endorse Mike West‘s datarequestor.js. It really does simplify AJAX. I recently had to build a tool that allows users to perform the inline editing of comments as mentioned above. The datarequestor script has a nifty and super simple way to dump all of a form’s fields and method into a request. This alleviates having to wrangle long comments into a GET url since a form can use POST and not suffer the 1024-character limit of URLs in IE.

So, if you want to dabble in AJAX and XHR, or if you already use XHR and need a super simple tool to handle all the code involved, I highly recommend you check out datarequestor.js.

Leave a Reply