jQuery AJAX request for a JSON WordPress feed

Here’s a method to get a JSON feed with jQuery (version 1.7.1 at time of writing). This may work in earlier versions of jQueruy but I have didn’t test it.

Code walkthrough:

  • Specify the feed URL. See notes in the code below for pre-requisites.
  • Before sending the request, set the “result” div to show an animated gif to indicate something’s happening
  • If there’s an error, display an error message in the “result” div
  • If successful, display the first 6 items from the feed in the “result” div


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s