Home > jQuery > jQuery getJSON

jQuery getJSON

An example of using getJSON to populate a dropdown list

$.getJSON("URL", null,
   function (data) {
      $.each(data.d, function (i, result) {
         var optionText = "<option value=" + result.value + ">" 
         + result.text + "<option>";
         $('#ddlSelectTagId').append(optionText);
      });
   }
);
Advertisements
Categories: jQuery
  1. Gamal
    March 9, 2013 at 6:15 PM

    Hi Amal,
    How do you create a web service to be consumed by that jquery code?

  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: