0

I use ajax in Arcgis Javascript (if you are familiar, i just inform you that i use it, never mind) to select some data and show it in modal window, but i have problem, e.g. i clicked several feature on map (e.g. 3 features) and on each click i get different info, but if i click info button again and again it shows these selected features one by one even though i have selected different feature on map, it stores data and does not show correct info when i continue click and get info from a map.

I use 'cache: false' in $.ajax but it's not working.

Any help please, i checked this article, but it didn't help.

here is a piece of code i use

    $(document).on('click', '#vf', function () // 
{  
   var folder_name = 'inv_images/' + graphic.attributes.Wis_invent_N;  
   var action = "fetch_files";
   $.ajax({ 
       url: "action.php",
       method: "POST",
       data:{
         action:action, folder_name:folder_name,
         },
       cache: false,
       success: function(data)
       {
           $('#file_list').html(data);
           $('#filelistModal').modal('show'); 
         }
      })
   });
});

1 Answers1

1

If it's the browser that's caching the ajax request (ex. IE does that) then you can change the actual request that's done by adding a timestamp to the url:

...
   $.ajax({ 
       url: "action.php?t=" + new Date().getTime(),
...

The backend should ignore the extra t parameter, but your browser thinks it's a different url therefore doesn't use the cached response.

Ziarno
  • 7,366
  • 5
  • 34
  • 40