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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:48:41+00:00 2026-05-23T15:48:41+00:00

OK so this is driving me insane.. I’m attempting to parse JSON from a

  • 0

OK so this is driving me insane..
I’m attempting to parse JSON from a web method into a <ul>, here’s what I’ve got:

function searchPostcode() {
    var search = $("#txtPostcode").attr("value");
    //alert(search);
    $.ajax({
        type: "POST",
        url: "DeliverySettings.aspx/getDeliveryInfoForPostcode",
        contentType: "application/json; charset=utf-8",
        data: "{'postcode':'" + search + "'}",
        dataType: "json",
        success: AjaxSucceeded,
        error: AjaxFailed
    });

    function AjaxSucceeded(result) {
        var items = [];

        $.each(eval(result), function (key, val) {
            items.push('<li id="' + key + '">' + val + '</li>');
        });

        $('<ul/>', {
            'class': 'my-new-list',
            html: items.join('')
        }).appendTo('jsonresults');

    }
    function AjaxFailed(result) {
        alert(result.status + ' ' + result.statusText);
    }
}

And here’s a sample of the JSON returned from the WebMethod:

[{"Name":"Full Pallet","Price":"90.0000"},{"Name":"Half Pallet","Price":"60.0000"},{"Name":"Quarter Pallet","Price":"40.0000"},{"Name":"Small Parcel","Price":"30.0000"},{"Name":"Medium Parcel","Price":"20.0000"},{"Name":"Large Parcel","Price":"10.0000"}]

I’ve tried with and without the eval to no avail, I just cant get into a list… Please help! 🙂

  • 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-23T15:48:41+00:00Added an answer on May 23, 2026 at 3:48 pm

    What is jsonresults? If it’s an ID, you forgot the #

    .appendTo('#jsonresults');
    

    Also, with this:

    items.push('<li id="' + key + '">' + val + '</li>');
    

    you’ll get [object Object] as the text content. I assume you want the Name. If so, do this:

    items.push('<li id="' + key + '">' + val.Name + '</li>');
    

    Also keep in mind that the key is the index of the Array. If you’re supporting HTML4, it isn’t valid to have an ID that starts with a number.

    You may want to change it to:

    items.push('<li id=product_"' + key + '">' + val.Name + '</li>');
    

    …or something similar.

    Example: http://jsfiddle.net/G8HqX/

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

Sidebar

Related Questions

Hoping someone can help me here as this is driving me insane. I used
This is driving me insane! Here's the code: public static void main(String[] strings) {
This is driving me insane, this is HTML code. <html> <head> <script> function init()
This is driving me insane. I have a JS file that is: Ext.onReady(function(){ Ext.QuickTips.init();
Any help most appreciated, this is driving me insane. I'm doing exactly what I
This is driving me absolutely insane. I know that, to change the formatting of
http://mehulkar.com/CD This is driving me insane. I have a fixed position header and a
I have this problem that is driving me insane. I have a project to
This is driving me insane. I'm trying to change the panels when you click
This has been driving me insane for about the last hour. I'm trying to

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.