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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:48:15+00:00 2026-06-10T04:48:15+00:00

I am trying to return some data retrieved from an xml file and then

  • 0

I am trying to return some data retrieved from an xml file and then return it to a view page.

The xml file will be updated during a certain action a user will start, and then i have a dialog box that pops up and displays the contents of the xml file. The xml file will be updated during this action.

In my view I want to display the data returned from the php action that reads the xml file.

Here is my action to get the updated xml file. This will be called every second to update the view.

public function getUpdate()
    {
        $myFile = '/srv/www/xml-status/update_status.xml';
        $file = fopen($myFile, 'r');
        $data = file_get_contents($myFile);
        //debug($data);
        //print_r($data);

        //echo json_encode($data);
        //echo $data;
        return json_encode($data);
    }

The contents of the xml file are retrieved and stored into the $data variable, but I keep getting a 500 internal server error. I tried a bunch of different things, but I don’t know how to return the data correctly.

Here is my view code to display the info.

<script>
window.onload = timedRefresh(1000);

// Get the updated xml file every second
function timedRefresh(timeoutPeriod)
{
    // Do a get request to get the updated contents of the xml file
    $.get('/tools/getUpdate', function(data)
    {
        alert(data);
    });

    window.setTimeout('timeRefreshed(1000)', 1000);
}
</script>

<?php
if(false != $xml = simplexml_load_file($xmlFile))
{
    foreach ($xml->LogEvent->sequence as $temp)
    {
        echo 'Step: ', $temp['step'], ' ', 'Step Name: ', $temp['stepName'], ' ', 'd1: ', $temp['d1'], ' ',
        'd2: ', $temp['d2'], ' ', 'd3: ', $temp['d3'], ' ', 'Status: ', $temp['status'],'<br>';
    }
}
else
{
    echo '<br>Error: Update status can\'t be displayed<br>';
}
?>

I can’t figure out what I am doing wrong. If I can get the data variable to be returned to the get request I can then parse through and display the info, but I am having trouble getting the data from php to the javascript get request.
Any help would be great.

Thanks

  • 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-10T04:48:17+00:00Added an answer on June 10, 2026 at 4:48 am

    I think your action would be like that :

    public function getUpdate()
    {
        $myFile = '/srv/www/xml-status/update_status.xml';
        $file = fopen($myFile, 'r');
        $data = file_get_contents($myFile);
        //debug($data);
        //print_r($data);
    
        echo json_encode($data);
        exit;
    }
    

    OR

     public function getUpdate()
    {
        $this->autoRender = false;
        $myFile = '/srv/www/xml-status/update_status.xml';
        $file = fopen($myFile, 'r');
        $data = file_get_contents($myFile);
        //debug($data);
        //print_r($data);
    
        echo json_encode($data);
    
    }
    
    • 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 some data from a PHP file which only gives a
I'm trying to return a string from a function. Which basically adds some chars
I am trying to get some data out from a database stored as text
I'm trying to retrieve some data from the FaceBook graph API. The API URL
I'm trying to retrive some data from a web site . I wrote a
I'm trying to parse some XML from the USGS. Here's an example The parameterCd
I am trying to retrieve some data from a database using jQuery's $.getJSON method
Hi I am trying to build an app where data are retrieved from a
I'm trying to make a query that must to retrieve some data from my
I have created a web service which returns some data and am 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.