简体   繁体   中英

PHP IE9 XML Issue

I have a page that displays XML info in a table. The XML files are server side and I'm using PHP to get the file names and data using a drop down box. JSON is used to put the names in the dropdown and DOM to send the XML across. That works fine in all browsers.

There is an issue with my adding entries feature. When I add an entry in Chrome or Firefox it shows up the next time that table is selected. It doesn't work in IE9 though. The entries are added to the xml file but to view these changes in IE I have to open a new tab. Simply refreshing doesn't work. To redirect in this script I use the header function:

header('Location: ./client2.html');

Is there something that needs to be added here for IE or is there an issue somewhere else. I've added the php that gets the data when the file is chosen.

ini_set('display_errors',1); 
error_reporting(E_ALL);

/* gets the selected file to use to return data */
$xml_filename = './XML/'.$_REQUEST['file'];
$xml = simplexml_load_file($xml_filename);

/* gets the root of the selected file */
$rootname = $xml->getName();
/* gets the children in that root */
$children = $xml->children();
$firstchild = $children[0];

// gets the table headings
$data = '{"headings":[';
foreach ($firstchild as $elem)
{
    $data = $data.'"'.$elem->getName().'",';
}

// removes trailing ','
$data = substr_replace($data,"",-1);
$data = $data.'],';

// gets the cell values
$data = $data. '"vals":[';
foreach ($children as $child)
{
    $data = $data.'[';
foreach ($child as $elem => $vals)
{
    $data = $data.'"'.$vals.'",';
}
$data = substr_replace($data,"",-1);
$data = $data.'],';
}

// removes trailing ','
$data = substr_replace($data,"",-1);
$data = $data.']}';

/* sends created JSON string back to client */
echo $data;

If it's a caching problem, you could try adding a random string in the header() call, like this:

$random_str = sha1(uniqid(mt_rand(), true));
header('Location: ./client2.html?' . $random_str);
exit();

Turns out it was a caching issue. I had to add this: $.ajaxSetup({cache:false}) to the document.ready() section of the JavaScript. Nothing else seemed to work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM