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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:58:27+00:00 2026-05-27T07:58:27+00:00

I have an AJAX statement that is meant to return echoed output from a

  • 0

I have an AJAX statement that is meant to return echoed output from a PHP script the output is XML.

If navigate directly to the PHP script it outputs the JSON in the exact format I need.

the “data” variable in the AJAX request is not returning it properly, even though firebug network tab says status 200 ok for request.

The PHP returning XML elements “MP3 and Title”

<?php
    $url = 'http://www.startalkradio.net/?page_id=354';
    $rss = simplexml_load_file($url);
    $items = $rss->channel->item;

    $i = 0;
    $data = array();
    foreach ($items as $item) {
        $data[] = array(
            'title' => (string) $item->title,
            'mp3'   => (string) $item->enclosure['url'],
        );
        if (++$i == 3) break;
    }

    $jsdata = json_encode($data);
    echo htmlspecialchars($jsdata, ENT_NOQUOTES, 'utf-8');
?>

AJAX call populating JPlayer script. data does not seem to be returned.

$(document).ready(function() {
    $.get(
        "http://www.freeenergymedia.com/getxml2.php", 
        function(data) {
            new jPlayerPlaylist({
                jPlayer: "#jquery_jplayer_1",
                cssSelectorAncestor: "#jp_container_1"
            }, 
            data, 
            {        <!-- here I am returning the php script to populate XML into JPlayer. -->
                swfPath: "js",
                supplied: "mp3, oga",
                wmode: "window"
            });
        }
    );
});

the link in question

Here is a version that works note that the XML is the same as what is output by the PHP script
link

  • 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-27T07:58:28+00:00Added an answer on May 27, 2026 at 7:58 am

    You say that you are returning XML but your PHP uses json_encode(). So your $.get() call should specify that:

    //using `$.getJSON()` will set the dataType property to json so your server-side output will be parsed into a JavaScript object
    $.getJSON(
            "http://www.freeenergymedia.com/getxml2.php", 
            function(data) {
                console.log(data);//<--use this to inspect the JSON object returned from the server, make sure it's in the proper format
                new jPlayerPlaylist({
                    jPlayer: "#jquery_jplayer_1",
                    cssSelectorAncestor: "#jp_container_1"
                }, 
                data, 
                {        <!-- here I am returning the php script to populate XML into JPlayer. -->
                    swfPath: "js",
                    supplied: "mp3, oga",
                    wmode: "window"
                });
            }
        );
    

    data should look something like this:

    data = [
        {"title":"some title", "mp3":"path to some song"},
        {"title":"some other title", "mp3":"path to some other song"},
        etc...
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I have an ajax jquery function that receives data from a php
I have an AJAX script that receives a string from a mySQL query returned
I have the following jQuery statement: $.ajax({ type: POST, url: db.php, data: word=+ tmpWord,
i have an ASP.net page that generates dynamic xml but the get statement of
I have a jquery script that collects data from different sites and saves it
I have jQuery Ajax request that sends data to a PHP page that then
I have a series of dynamically generated inputs that I need to have ajax
I am using asp.net MVC to develop an application that will have ajax interactions.
I have some AJAX work that brings across an additional form element that I
I have a function that (via ajax) I pass a Guid and a comma

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.