'Timestamp AJAX URL
Below is the code I'm using for jQuery BBQ.
$(function(){
var cache = {
'': $('.content')
};
$(window).bind( 'hashchange', function(e) {
var url = $.param.fragment();
$( '.contentarea' ).children( ':visible' ).hide();
if ( cache[ url ] ) {
cache[ url ].show();
} else {
$( '.content-loading' ).show();
cache[ url ] = $( '<div class="pageURL"/>' )
.appendTo( '.contentarea' )
.load( url, function(){
$( '.content-loading' ).hide();
});
}
$('#wrapper').scrollTop(0);
})
$(window).trigger( 'hashchange' );
});
</script>
I need to amend the code so that the URL is timestamped. I tried using the following code, but when I did the whole page stopped working:
var url = $.param.fragment()+str;
var date = new Date();
var timestamp = date.getTime();
url=url+'&time='+timestamp;
Any help would be appreciated.
Solution 1:[1]
The character & is used for the second value pairs. For the first instance, use ? as such:
url=url+'?time='+timestamp;
Also, if ever using & in URL you may need to use the escaped version &
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | arttronics |
