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