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 8174681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:31:27+00:00 2026-06-06T22:31:27+00:00

Retrieve code from json. C#code:- var collection = getsortcat.Select(x => new { idterm =

  • 0

Retrieve code from json.

C#code:-

var collection = getsortcat.Select(x => new
        {
            idterm = x.IDTerm,
            mvo = x.MVO,
            pic = x.Pic,
            said = x.SAid,
            termactive = x.TermActive,
            vid = x.Vid,
            fvo = x.FVO,
            eterm = x.ETerm,
            edef = x.EDef,
            buse = x.BUse,
            bterm = x.BTerm,
            idcat = x.TermCat,
            items = x.TermCategory1.IDCat,
            catname = x.TermCategory1.TermCategory1
        });
        JavaScriptSerializer jss = new JavaScriptSerializer();
        string output = jss.Serialize(collection);
        return Json(output, JsonRequestBehavior.AllowGet);

Javascript Code:-

success: function (e) {
                    var txt = "'{ data :" + e + "}'";
                    var obj = eval("(" + txt + ")");
                    $('#pdata').append(obj.data[0]);
                },

Not getting output. Please give me solution how to retrieve data from c# linq object to json to html?

  • 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-06-06T22:31:28+00:00Added an answer on June 6, 2026 at 10:31 pm

    First fix your controller action to get rid of any JavaScriptSerializers and manual plumbing code. Directly return the collection to the Json result:

    var collection = getsortcat.Select(x => new
    {
        idterm = x.IDTerm,
        mvo = x.MVO,
        pic = x.Pic,
        said = x.SAid,
        termactive = x.TermActive,
        vid = x.Vid,
        fvo = x.FVO,
        eterm = x.ETerm,
        edef = x.EDef,
        buse = x.BUse,
        bterm = x.BTerm,
        idcat = x.TermCat,
        items = x.TermCategory1.IDCat,
        catname = x.TermCategory1.TermCategory1
    });
    return Json(collection, JsonRequestBehavior.AllowGet);
    

    Now inside the success callback the e parameter already represents an array of objects that were parsed. You don’t need to call any eval. Directly access the elements (by index) and then the properties:

    success: function (e) {
        var txt = e[0].mvo;
    },
    

    you could also loop through the elements:

    success: function (e) {
        for (var i = 0; i < e.length; i++) {
            var element = e[i];
            alert(element.idterm);
        }
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to retrieve a json string from my webserver: var
I retrieve embed code videos from my database. However, in db they are 650
I am trying retrieve user name from the code through graph api, the below
I've rolled my own code to retrieve data from remote URLs using a HttpURLConnection.
I tried several ways to retrieve datetime2(3) equivalent from C# code but in vain.
I'm using a standard couple of lines of code to retrieve a key from
I found this code snippet to retrieve the title from a YouTube video and
I want to retrieve all clientID from my MCC account. I'm using this code
I am trying to retrieve DataTable from .xls file. Below are my code: OleDbConnection
I am trying to retrieve JSON formatted data from a remote domain (Zencoder video

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.