title: AJAX not alway updating
body: <p>I have a Spring MVC controller which returns simply a 0/1 value.</p>
  
  <p>This is my controller</p>
  
  <pre><code>@RequestMapping(value="/{idPiano}")
      public String showFloorMap(ModelMap model, @PathVariable int idPiano){
          Piano piano = pianoService.findById(idPiano);
          String filename = piano.getFileName();
          model.addAttribute("idPiano", idPiano);
          model.addAttribute("filename", filename);
          return "floors/map";
      }
  
      @RequestMapping(value="/ajax/{idPiano}", method = RequestMethod.GET)
      public @ResponseBody int loadMap(@PathVariable int idPiano){
  
          int result = updateMap.checkMap(idPiano);
  
              return result;
      }
  </code></pre>
  
  <p>map.jsp is the following:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      function updateMap() {
  
          $.ajax({
              url : 'ajax/${idPiano}',
  
              success : function(data) {
                               if(data===1) {
                      $('#result').append("&lt;img src=\"/uploads/"+$('#filename').val()+"\" /&gt;");
                  }
  
              }
          });
  
      }
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
      var intervalId = 0;
      intervalId = setInterval(updateMap, 5000);
  &lt;/script&gt;
  
  &lt;title&gt;&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;input type="hidden" id="filename" value="${filename }"/&gt;
  &lt;div class="row"&gt;
  &lt;div id="result"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So, every 5 seconds i call the function updateMap, I check if it's 0 or 1, I should append into the div the image.
  This happens only the first time, but the 0 and 1 are correctly sent to the page.. which is the problem?</p>