0

I'm having issues with my module. There are different steps involved and I'm not sure where it is hanging up at.

I'm using an xml file for storage of data. When I add information via my php call, everything works fine. It is if I need to edit that same file right away that it seems that the ajax call to load the data cannot find the file.

1 - I use php on the server side to write the data from the html page to the xml file. I utilize fopen/fclose for this file.

2 - When I'm needing to edit the data, I read the file in and add the information.

3 - If I notice I have a typo or something and need to edit the data immediately afterwards, the ajax call doesn't find the file. But the file is there and has been written properly. If I wait like an hour or so and come back to it, it works fine too.

Is there something with fclose that may not be unlocking the file?

  • How are you opening the file? – Explosion Pills Sep 05 '13 at 18:48
  • When I write to the file, I use fopen($file, 'w'), then write to it, then fclose it. – Lisa Komidar Sep 05 '13 at 19:02
  • When I'm in the browser loading the information to be edited, I open with an ajax call (which works when you are adding new information to the file). The ajax call only does not work if I'm going right back in and trying to edit the information. – Lisa Komidar Sep 05 '13 at 19:03
  • This is the php to read, write and close: – Lisa Komidar Sep 05 '13 at 19:07
  • 1
    $fh = fopen($path.'/common/corefiles/announcements.xml', 'wb') or die ("Failed to open ".$course->request); fwrite($fh, $xml->asXML()); fclose($fh); This is the ajax call in the html:var xml_file = (""); jQuery(function(){ $.ajax({ type: "GET", url: xml_file, dataType: 'xml', success: function(xml) { var titlestring; var i = 0; var arry = new Array; $(xml).find('entry').each(function(){ // do stuff here but it doesn't get here on editing right after the initial edit }); }); – Lisa Komidar Sep 05 '13 at 19:10

0 Answers0