Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 679695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:17:19+00:00 2026-05-14T01:17:19+00:00

I’ still newby to this so I’ll try to explain what I’m doing. Basically

  • 0

I’ still newby to this so I’ll try to explain what I’m doing. Basically what I want is to load a dropdownlist depending on the value of a previous one, and I want it to load the data and appear when the other one is changed. This is the code I’ve written in my controller:

public ActionResult GetClassesSearch(bool ajax, string phylumID, string kingdom){
  IList<TaxClass> lists = null;
  int _phylumID = int.Parse(phylumID);
  int _kingdom = int.Parse(kingdom);
  lists = _taxon.getClassByPhylumSearch(_phylumID, _kingdom);
  return Json(lists.count);
}

and this is how I call the method from the javascript function:

function loadClasses(_phylum) {
 var phylum = _phylum.value;

 $.getJSON("/Suspension/GetClassesSearch/",
         { ajax: true,
             phylumID: phylum,
             kingdom: kingdom
         },
         function(data) {
             alert(data);
             alert('no fallo')
             document.getElementById("pClass").style.display = "block";
             document.getElementById("sClass").options[0] = new Option("-select-", "0", true, true);
             //for (i = 0; i < data.length; i++) {
             //   $('#sClass').addOption(data[i].classID, data[i].className);
             //}
         });

}

The HTML associated is:

<p id="pPhylum">
                <%= Html.Label("Phylum: ") %>
                <%= Html.DropDownList("sPhylum",
                          (SelectList)ViewData["PhyRecID"],
                      "--Select One--",
                      new { onchange = "loadClasses(this);" }
                      )%>
</p>
<p id="pClass">
                <%= Html.Label("Class: ") %> <select id="sClass"></select>
</p>

The thing is that just like this it works, I pass the function the number of classes within a selected phylum, and it displays the pclass element, the problem gets when I try to populate the slist with data (which should contain the objects retrieved from the database), because when there is data returned by the database changing return Json(lists) instead of return Json(lists.count) I keep getting the same error:

A circular reference was detected while serializing an object of type ‘SubSonic.Schema.DatabaseColumn’.

I’ve been going round and round debugging and making tests but I can’t make it work, and it is suppossed to be a simple thing, but I’m missing something. I have commented the for loop because I’m not quite sure if that’s the way you access the data, because I’ve not been able to make it work when it finds records. Can anyone help me?

Thanks in advance,
Victor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:17:20+00:00Added an answer on May 14, 2026 at 1:17 am

    Finally I solved this problem. The problem was that JSON for some reason wasn’t capable of displaying objects that are referenced to each other, that have problems with foreign keys and stuff. I created a new class just with the fields I needed from the database, and I populated it with a foreach statement. Then I passed that filled IList to the return Json and it worked…

    Thank you all for your help,
    Victor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.