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

  • Home
  • SEARCH
  • 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 8576353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:54:21+00:00 2026-06-11T19:54:21+00:00

I was looking on internet for over 2 hrs now, trying to find simple

  • 0

I was looking on internet for over 2 hrs now, trying to find simple example of how to fill jQuery Variable from serverside code on load of asp.net page.

What i have so far:

I have a button which call this jquery code:

    function GetListOfQuestions() {
        $.ajax({
            type: "POST",
            url: 'UserProfile.aspx/getQuestions',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            error: OnAjaxError,
            success: AjaxSucceeded
        });
        //$.getJSON('UserProfile.aspx/getQuestions', {}, function (data) {
        //    alert(data);
        //});
    }

    function AjaxSucceeded(result) {

        alert(result);

    }

GetListOfQuestions calls serverside :

    [WebMethod]
    public static List<Question> getQuestions(){

        var userGuid = (Guid)System.Web.Security.Membership.GetUser().ProviderUserKey;
        IEnumerable<Question> list = Question.getQuestionsForUser(userGuid).Select(x => new Question
        {
            Uid = x.Uid,
            Content = x.Content
        });

        return list.ToList();
    }

result return an object if I alert it, so it must contain some kind of data, but I can’t find any example of how I can retrieve data again on client side.

I’m not sure if what I am doing right now is right at all (I’m new to jQuery). So how can I retrieve data from result variable again?

  • 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-11T19:54:22+00:00Added an answer on June 11, 2026 at 7:54 pm

    There could be better ways but this is one way I know of:

    [WebMethod]
        public static string getQuestions(){
    
            var userGuid = (Guid)System.Web.Security.Membership.GetUser().ProviderUserKey;
            IEnumerable<Question> list = Question.getQuestionsForUser(userGuid).Select(x => new Question
            {
                Uid = x.Uid,
                Content = x.Content
            });
    
            return new JavaScriptSerializer().Serialize(list.ToList())
        }
    

    In your jQuery method, you can

    result = $.parseJSON(data) ;
    

    Do a console.log(result) to see how to iterate through result, should be just a for loop.

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

Sidebar

Related Questions

Now I feel like I've been looking all over the internet to find out
I've looked all over the internet and can't seem to find what i'm looking
I've looked all over the internet trying to find an answer to my problem,
I've been looking all over the internet and I can't find an acceptable solution
I've been looking all over the internet for an answer, and I didn't find
I have been looking over the internet, but could not find the perfect tutorial
I have been scouring the internet for over a week now looking for a
I have a little / weird behaviour here and Im looking over internet and
I have been looking over the internet for a while about this, but it
I have been looking all over the internet and i found some good guides

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.