0

I am getting an unusual response from a jQuery to populate a select List. firstly, here is the ajax call;

 loadShowAllReports = function() {
$.ajax({
        url: "cfc/Reports.cfc"
        , type: "get"
        , dataType: "json"
        , data: {
             method: "jGetShowAll"
        },
      success: function(response) {
          console.log(response);
          $.each(response.DATA, function(i, row) {
              // get value of first row as description;
              var val = row[0];
              var descr = row[1]
              // append new options
              $("##cboShowAllReports").append($("<option/>", {
                  value: val,
                  text: descr
              }));
              // set it while firing, so its available when done
              // 1 = default 'Active' to start with
          });

          $('##cboShowAllReports option:selected').val(getValue('rShowAll'));
          loadReports($(this).find(':selected').val());
          loadReportsActive();
          loadReportTypes();
      },
      error: function(msg) {
          console.log(msg);
      }
  });

That should return 3 simple value-pairs Active, InActive and All, yet the first value is [object Object]. I have several other populated dropdowns on this page, but two of them are being created with this [object Object]. The getValue() is a coldfusion sessionMgr.cfc that gets and sets session variables.

offendingSelect offendingSelect

I thought it was populating the [COLUMNS] data until I dumped to the console.log and the array looks fine. I am unsure what is doing this, any help? I have been fighting this for days and have run out of ideas.

so I added console.log('on population: ' + var); and it shows;

offendingSelect

BigBear
  • 59
  • 4
  • Put a `console.log( val )` after `var descr = row[1]` what is it returning 1st time? – palaѕн Mar 11 '20 at 13:40
  • I added console.log('on population: ' + val); and it returned on population: 0, on population: 1, on population: 2 – BigBear Mar 11 '20 at 14:29

1 Answers1

0

so digging further into the code, I had left 2 serializeJSON() for the resultsets in the CFCs for this and another select population;

<cfset var Reports = structNew() />
<cfset Reports = serializeJSON(qReports) />
<cfreturn Reports />

which was wddx'ing the package creating the initial [object Object]. So in the future, make sure you are right before you are wrong. =]

BigBear
  • 59
  • 4