0

I am trying to update my page variables after an ajax request to an external page without reloading the current page. My current page is mysite.com/page?arrival=11/02/2019&departure=12/02/2019

On ajax success I update my url without refreshing the page with window.history.pushState but I can't manage to update my variables. The url changes to mysite.com/page?arrival=15/07/2019&departure=16/07/2019 but when I request from autocomplete $_GET['arrival'] it returns the original value "11/02/2019" I want to return the new value "15/07/2019" returned from ajax request

$('#unitrate').submit(function() {
  {
    $.ajax({
      url: \"part-xml-room-ajax.php\",
      type: \"GET\",
      data: $('#unitrate').serialize(),
      beforeSend: function() {
        $(\"#xml-info-hide\").show();
        $(\"#xml-info\").hide();
      },
      success: function(result) {
        $('#xml-info').html(result);
        window.history.pushState(\"Details\", \"Title\", ('?&'+$('#unitrate').serialize()));                                        
        $(\"#xml-info-hide\").hide();
        $(\"#xml-info\").show();                             
      }
    });
  }
  return false;
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Antonios
  • 5
  • 2
  • similar: https://stackoverflow.com/questions/22577457/update-data-on-a-page-without-refreshing – Mebin Joe Feb 11 '19 at 10:07
  • I can return the html content in #xml-info div but I can't update the variables on a new request from the page. It reads the old variables. – Antonios Feb 11 '19 at 10:33

0 Answers0