Does jquery require a timestamp for GET calls in IE7?

See jQuery code below, it is used to break down some search results

paginate: function() { $("#wishlistPage .results").html("<div id='snakeSpinner'><img src='"+BASE_URL+"images/snake.gif' title='Loading' alt='...'/></div>"); var url = BASE_URL+"wishlist/wishlist_paginated/"; $.ajax({ type: "GET", url: url, data: { sort_by:$('#componentSortOrder input:hidden').val(), offset:My.WishList.offset, per_page: 10, timestamp: new Date().getTime() }, success: function(transport){ $("#wishlistPage .results").html(transport); } }); }, 

My problem is not related to pagination, the problem is when I need to call the same function, when something happened to another part of the page that deletes some search results, it brings old results to IE7, other browsers work fine. Therefore, a timestamp has been added: new date (). GetTime (). This fixed the IE problem.

I want to know why this is happening in jQuery? Do I need to include a timestamp parameter in the url to avoid caching in all jQuery Ajax calls?

+4
source share
1 answer

In short, yes . IE doesn't usually obey caching rules, but jQuery can also automatically add this parameter for you, just use the cache: false parameter cache: false , like this

  $.ajax({ type: "GET", url: url, cache: false, data: { sort_by:$('#componentSortOrder input:hidden').val(), offset:My.WishList.offset, per_page: 10, timestamp: new Date().getTime() }, success: function(transport){ $("#wishlistPage .results").html(transport); } }); 

The result is the same, it adds the timestamp of the URL, you can see the code here .

+10
source

Source: https://habr.com/ru/post/1312856/


All Articles