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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:56:13+00:00 2026-06-12T19:56:13+00:00

I am returning a JSON array to my jQuery function script, but cannot seem

  • 0

I am returning a JSON array to my jQuery function script, but cannot seem to get the syntax correct — even after reading about a dozen different examples here.

Here is the calling jQuery ajax function:

$.ajax({
    url: "fetchAlleles.php",
    datatype: 'json',
    data: {'mndx': mndx, 'sndx': sndx },
    success: function(rtnval) {
      alert("success: allele_1="+rtnval['allele_1']+", allele_2="+rtnval['allele_2']);
      //alert(rtnval);
    },
    error: function() { alert('Error!'); }
    });

Here is the PHP code that returns the values:

echo "{";
echo "allele_1: ", json_encode($ary[0]), "\n";
echo "allele_2: ", json_encode($ary[1]), "\n";
echo "run_date: ", json_encode($ary[2]), "\n";
echo "}";

If I use my alert debugging statement, I can see what’s being returned is what I expect:

{allele_1: "440"
allele_2: "480"
run_date: null
}

but anything else I try to read the values inside the JSON object comes back “undefined”, whether it’s

alert("success: allele_1="+rtnval['allele_1']+", allele_2="+rtnval['allele_2']);

or

alert("success: allele_1="+rtnval.allele_1+", allele_2="+rtnval.allele_2);

or

alert("success: allele_1="+rtnval['allele_1'][0]+", allele_2="+rtnval['allele_2'][0]);

Hope someone can help — this is exasperating! (Wish JSON syntax were more obvious!)

thanks much,
rixter

  • 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-12T19:56:14+00:00Added an answer on June 12, 2026 at 7:56 pm

    Use jQuery.parseJSON to make this easier http://api.jquery.com/jQuery.parseJSON/

    Here’s their example:

    var obj = jQuery.parseJSON('{"name":"John"}');
    alert( obj.name ); //John
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem returning/processing JSON data while calling $.get() function. Here's the code:
I am using the Zend Framework helper for JSON. I am returning an array
I'm returning some Json via a C# MVC Controller. Other browsers work fine, but
I'm quite new to the whole jQuery/JSON thing but thought I would give it
I have the following php script that is called by jquery ajax function report_range($time,
Something weird is going on, my AJAX Request is returning a array but the
Very new to both JSON and jQuery , but here is what I am
I am using jQuery to get a list of Names as JSON string -
I have problems returning JSON data after using Uploadify. This code works in Firefox,
I am passing a multidimensional array back to a .php file using json, jquery,

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.