How to update an XML file without reloading the page

Asked

Viewed 240 times

0

Good afternoon, I am creating an application that loads functions based on the information of a given XML file. However, once I save a new function via php, when I go to do a Xhttprequest in javascript the code remains the same. I have tried using requestHeader("cache-control", "no-cache") but am still having problems. Does anyone know a solution to my problem? I’m using cache-control improperly? Any help is appreciated

EDIT: Resolved as in the answer, I found out what I was doing wrong.

1 answer

0


Cache-control cannot be used in requests, only in Sponses, you can create a php file that returns your xml file every time it is called. See the code below:

$xmlfile = file_get_contents ( "myfile.xml" );
header ( "Cache-Control: no-cache" );
header ( "Pragma: no-cache" );
header ( "Content-type: text/xml" );
echo $xmlfile;

This way you can return the file and every time a new request is made, no cache will be used.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.