Jump to content

problem with cache?


c_pattle

Recommended Posts

I have some JavaScript that sends an AJAX request to the following PHP script every 4 seconds.  The idea behind this is that every 4 seconds a new, randomly generate piece of content is loaded.  This works fine in Firefox and Chrome, however when I test it in IE it seems to just load the same piece of content over and over again.  I'm pretty sure there is nothing wrong with the script so could this be something to do with IE caching the first piece of content returned?  Thanks for any help. 

 

$random_number = 0;
$random_number = rand(1,6);

if ($random_number == 1 ) {

echo("<a href=\"\"><h4>Aliquam erat volutpat. Vivamus feugiat tempor quam, faucibus elementum.</h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae ante at erat tempor facilisis. Quisque blandit faucibus suscipit. Proin suscipit est sed. </p></a>");

} 

if ($random_number == 2) {

echo("<a href=\"\"><h4>Quisque ac lacus nibh, ac semper ante. Sed imperdiet.</h4><p>Vestibulum aliquam pellentesque lacus quis mollis. Proin quis lobortis libero. Ut nec tempor lectus. Pellentesque habitant morbi tristique senectus et netus id. </p></a>");

}

if ($random_number == 3) {

echo("<a href=\"\"><h4>Suspendisse vestibulum dui augue, nec viverra erat. Proin id.</h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu sollicitudin elit. Cras mauris mi, luctus non luctus quis, tristique vitae turpis turpis duis. </p></a>");

}

if ($random_number == "4") {

echo("<a href=\"\"><h4>Vestibulum gravida elit posuere arcu.</h4><p>Phasellus sit amet rutrum purus. Cras vulputate pretium quam eleifend viverra. Morbi convallis eros ac tellus suscipit nec euismod nibh semper. In quam posuere. </p></a>");

}

if ($random_number == "5") {

echo("<a href=\"\"><h4>Vestibulum ante ipsum primis in.</h4><p>Aliquam consectetur aliquet libero. Mauris malesuada tortor eu ipsum mollis sit amet blandit erat sollicitudin. Cras consequat dui ac elit semper pharetra amet. </p></a>");

}

if ($random_number == "6") {

echo("<a href=\"\"><h4>Nam ornare, nisl non interdum aliquam, erat urna consequat elit, vel.</h4><p>Nulla ut libero est, eu convallis urna. Nullam fringilla mollis ligula, id fringilla enim sagittis non. Nunc lectus nunc, condimentum eget imperdiet massa nunc.</p></a>");

}

Link to comment
Share on other sites

Thank you.  Although I am having some trouble with my timestamp.  When I try to print out the time stamp to the screen it just says "undefined".  Am I doing anything wrong?

 

var rand;

// Setting the interval so that the function executes every 4 seconds
setInterval(function(contentFeed) {

rand = contentFeed.timeStamp;
alert(rand);

	$.ajax({

		type: "GET",

		url: "feed.php",

		success: function(data) {
				alert("success");
		}

	});

}, 4000);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.