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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:17:21+00:00 2026-05-19T23:17:21+00:00

I am trying to get a Ajax-call made from jQuery to return a JavaScript

  • 0

I am trying to get a Ajax-call made from jQuery to return a JavaScript array generated by PHP, but can’t get it accessible. Here is what I am doing:

  1. I run the following code onLoad:
    $(function() {
    jQuery.ajax({
    url: 'retrieve.php',
    success: function(data) {
    },
    async: false
    }, "script");

  2. retrieve.php returns the following (retrieve.php does the formatting, and echoes it out):
    var data = {
    "info" : [{
    "title": "Title",
    "description": "Description"
    }],
    "playlist" : [
    {
    "title": "In This Place",
    "subTitle": "Excalibur",
    "href": "http://localhost/manger/ny/#desemberkonsert_in-this-place",
    "url": "../flv/desemberkonsert/21_in_this_place.flv",
    "thumbnail": "../flv/desemberkonsert/21_in_this_place_thumbnail.png",
    "time": "5:39"
    }, {
    "title": "Black Hole",
    "subTitle": "Excalibur",
    "href": "http://localhost/manger/ny/#desemberkonsert_black-hole",
    "url": "../flv/desemberkonsert/22_black_hole.flv",
    "thumbnail": "../flv/desemberkonsert/22_black_hole_thumbnail.png",
    "time": "4:26"
    }]
    }

  3. I then try to access this code using for example: $("#placeholder").text(data.playlist[0]["title"]);

  4. This returns as “undefined”

The array does work when I copy and paste it directly onto the file, but when returned as a callback it fails. How do I access the returned array?

  • 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-19T23:17:21+00:00Added an answer on May 19, 2026 at 11:17 pm

    You should return just the object, not a string of JavaScript which assigns the object to a name. That’s NOT a JSON response.

    Your code which uses the object should be in the success handler of the ajax call, not separate code somewhere else.

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

Sidebar

Related Questions

I'm trying to get a return value from an ajax call but I keep
I'm trying to get a JSON from a webservice with javascript $.Ajax call. <script
I'm trying to get the success data from a jquery Ajax call so I
I am trying to make a jQuery get() AJAX call, but the response is
I am trying to use jquery ajax to get data from a php file.
I am trying to get the response from ajax call and save it in
I'm trying to generate some XML for a jQuery.get (AJAX) call, and I'm getting
I'm trying to get my AJAX call working with the rails 3, but I'm
I am trying to get a jQuery.ajax to call back to the calling instance
I'm trying to get a file using an Ajax call in JQuery as follows:

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.