Skip to content

Populate ASPxCombobox on clientside with JSON data from jQuery

February 10, 2012
$(document).ready(function () {
    getParts();
});

function getParts() {
    $.ajax({
        type: "POST",
        url: location.pathname + "/Parts",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        datatype: "jsondata",
        success: function (response) {
            var parts = eval(response.d);
            cboParts.BeginUpdate();
            cboParts.ClearItems();
            for (var i = 0; i <= parts.length - 1; i++) {
                cboParts.AddItem(parts[i].Name, parts[i].Number);
            }
            cboParts.EndUpdate();
        },
        error: function (response) {
            alert(response.responseText);
        }
    });
}
    
Advertisements
One Comment
  1. thomas permalink

    Thanks
    This saved my evening!

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: