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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:56:10+00:00 2026-06-10T01:56:10+00:00

I am making a call to a webservice from jquery and trying to return

  • 0

I am making a call to a webservice from jquery and trying to return an List (I have also tried a string[]). When I get the results back I can see it holds an array with the values I need, but I can not iterate through them in Javascript because there is no length value.

my C# Webservice is as follows:

    [WebMethod]
    public string[] GetMultiChoiceOptions(int keyId)
    {
        string connectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["OBConnectionString"].ConnectionString;
        SitesUtil db = new SitesUtil(connectionString);
        List<MultiChoiceOption> keys = db.GetMultiChoiceOptions(keyId, 1); //TO DO CHANGE THIS TO REAL USERID

        return keys.Select(a => a.OptionValue).ToArray();
    }

and My Jquery/javscript call is as follows:

function GetKeys(keyid) {

    var pageUrl = '<%=ResolveUrl("~/WebService/UpdateDatabase.asmx")%>'
    $.ajax({
        type: "POST",
        url: pageUrl + "/GetMultiChoiceOptions",
        data: '{keyId:' + keyid + '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: GetKeysSuccessCall,
        error: OnErrorCall
    });
}

function GetKeysSuccessCall(response) {
    /* TO DO */
    var i = 0;
    for (i =0; i < response.length; i++) {
        $("#popupList").append('<li>' + response[i] + '</li>');                
        }       
}

I’m not sure how I deal with an array without a length in javascript?

  • 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-10T01:56:12+00:00Added an answer on June 10, 2026 at 1:56 am

    First, use Google Console. Best and helpful.

    To see what you receive, use console.log(response); (instead of alert and do NOT use in IE because it doesn’t know console)

    try first of all

    $.ajax({
            type: "POST",
            url: pageUrl + "/GetMultiChoiceOptions",
            data: '{keyId:' + keyid + '}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response){
              GetKeysSuccessCall(response);
            },
            error: function(msg) {
               OnErrorCall(msg);
             }
        });
    

    And one more :

    function GetKeysSuccessCall(response) {
        /* TO DO */
        var i = 0;
        for (i =0; i < response.length; i++) {
            $("#popupList").append('<li>' + response[i] + '</li>');                
            }       
    }
    

    repsonse must be instead of item

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

Sidebar

Related Questions

Ok I am making a call to a web service to get policies back.
I'm making call to Alfresco Webscripts which return JSON. I do this using GET
I have a main page from where I am making a call to load
I am making a webapp with Jquery Mobile. I got my data back from
I am making a webservice call that needs and authentication password using jquery ajax.
I'm trying to call an ASP.NET .asmx webservice, from javascript, using other than the
I am making a call to a web service, the results of the web
I'm making a RESTful web service call in my JavaScript page and get the
I've got an html page from where Im making this call periodically: function logon(id)
I'm trying to get a jsonp callback working using jquery within a greasemonkey script.

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.