I can not get this combo to work with an example from jQuery in
action. I'm trying to port the examples from jsp to .net. I'll post
the least amount of code. What I've learned is that the $.getJason
will not work on .Net because of the handler (not sure if this is true
but either method does not work), .Net will only process post request
for json.

<script type="text/javascript">
      $(function(){
        $('#styleDropdown')
          .change(function(){
            var styleValue = $(this).val();
            $('#detailsDisplay').load(
              'getDetails.aspx',
              { style: styleValue }
            );
            adjustColorDropdown();
          })
          .change();
        $('#colorDropdown')
          .change(adjustSizeDropdown);
      });

      function adjustColorDropdown() {
          var styleValue = $('#styleDropdown').val();
          var dropdownSet = $('#colorDropdown');
          if (styleValue.length == 0) {
              dropdownSet.attr("disabled", true);
              $(dropdownSet).emptySelect();
          }
          else {
              dropdownSet.attr("disabled", false);
               //
              $.ajax({ type: "POST", contentType: "application/json;
charset=utf-8",
                  url: "getColors.aspx",
                  data: "{}",
                  dataType: "json",
                  success: function(data) {
                      $('#errorDisplay').css('display', 'none');
                      $(dropdownSet).loadSelect(data);
                      adjustSizeDropdown();
                  },
                  error: function(xhr) {
                      $('#errorDisplay').html('Error getting colors: '
+ xhr.status + ' ' + xhr.statusText);
                      $('#errorDisplay').css('display', 'block');
                  }
              });
          }
      }

      function adjustSizeDropdown() {
          var styleValue = $('#styleDropdown').val();
          var colorValue = $('#colorDropdown').val();
          var dropdownSet = $('#sizeDropdown');
          if ((styleValue.length == 0) || (colorValue.length == 0)) {
              dropdownSet.attr("disabled", true);
              $(dropdownSet).emptySelect();
              adjustSizeDropdown();
          }
          else {
              dropdownSet.attr("disabled", false);
              $.ajax({ type: "POST", contentType: "application/json;
charset=utf-8",
                  url: "getSizes.aspx",
                  data: "{}",
                  dataType: "json",
                  success: function(data) {
                      $('#errorDisplay').css('display', 'none');
                      $(dropdownSet).loadSelect(data);
                      adjustSizeDropdown();
                  },
                  error: function(xhr) {
                      $('#errorDisplay').html('Error getting colors: '
+ xhr.status + ' ' + xhr.statusText);
                      $('#errorDisplay').css('display', 'block');
                  }
              });
          }
      }
    </script>

Reply via email to