Skip to content

Adding Selector Support to jQuery.get() to get page fragments

by benbarnett on March 9th, 2011

Just wrote a little plugin whilst working on a project because I keep finding myself using this functionality and having to write a handler in my application code. This plugin can be dropped in, just like jQuery Animate Enhanced and weighs in at less than 1KB, and it will enable you to quickly grab a partial or fragment of the AJAX endpoint.

Here’s some dummy code:

There’s not really much more I can say about this. Its unobtrusive, light weight and will simply hand over to the native jQuery.get() method if no selector is supplied.

Further Resources

From → Techniques

2 Comments
  1. Google Chrome is causing troubles with documents that contain a doctype. If the page requested contains , Google Chrome throws an error “INVALID_STATE_ERR: DOM Exception 11″.

  2. benbarnett permalink

    That’s a security error usually triggered when grabbing a file locally. Make sure you’re running from a webserver and not on a file:// type URL. Let me know if you’re still having issues.

Comments are closed.