This script does not work in firefox, why can it be?

<script type="text/javascript"> $(document).ready(function(){ $("#widget_languages li a.lang_btn").click(function() { name = $(this).attr('datalang'); $.post("lang", {'name': name}); location.reload(); }); }); </script> 
  • Show the browser console with errors. - Visman

2 answers 2

Alternatively, try calling location.reload() only if the request is successful in the success callback function.

 <script type="text/javascript"> $(document).ready(function(){ $("#widget_languages li a.lang_btn").click(function() { name = $(this).attr('datalang'); $.post("lang", {'name': name}, function( data ) { location.reload(); }); }); }); </script> 

PS Since you are using ajax, then maybe it is worth refusing to reload the page? And just in the same place in success , display the necessary information on the page using javascript.

  • Thanks helped. - Sergey Rumyantsev

After sending an AJAX request, you immediately call location.reload(); . The request does not have time to go, and the page reloads.

Refresh the page only after you receive a response to the request.