closing xml file after data acquired

closing xml file after data acquired

OK, I am back to this issue. I am doing a post and then once it's complete an ajax GET.  The problem I am running into is the on the server side they are writing output to an XML file, which I then read. The first step they want to do is delete xml file, which apparently they can't do because Javascript seems to keep the file open. So how do I close the file so they can delete. Here the general code for my routine:

  1. $(document).ready(function(){
                //post to plan.jsp
                var qString = '';
                $('#execute').click(function(){
                qString = $('#query-string').val();
                console.log(qString);
                $.post(
                    'plan.jsp',
                    {q:qString},
                    'xml'
                     ).done(function(data){
                                 
                   $.ajax({
                   type:'get',
                   url:'result.xml',
                   beforeSend: function(){$('#query-results').html('<img src="ajax-loader.gif"><br>Loading...'); },
                   timeout: 10000,
                   error: function(xhr, status, error){
                    alert("Error: " + xhr.status + " - " + error)
                   },
                   dataType: "xml",
                   cache:false,
                   success: function(data){
                   
                   var html = '<h3>Query Results</h3>';
                   html += '<table><tbody><tr>';  and blah, blah, blah and so forth