cascading dropdown in asp.net using ajax code example

Example: cascading dropdown in asp.net using ajax

$("#categoryDropDownList").change(function (e) {
    $.ajax({
        type: "POST",
        url: "index.aspx/bindproduct",
        contentType: "application/json; charset=utf-8",
        data: '{"categoryId":"' + $(this).val() + '"}',
        dataType: "json",
        success: function (result, status, xhr) {
            $("#productDropDownList").html(result.d);
        },
        error: function (xhr, status, error) {
            alert("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText)
        }
    });
});
  
$(document).ajaxStart(function () {
    $("img").show();
});
  
$(document).ajaxStop(function () {
    $("img").hide();
});

Tags:

Misc Example