simon551 Posted November 25, 2009 Share Posted November 25, 2009 I'm stuck. I have a page that loads json data and has a link that takes you to another page where you update info through an ajax post. I'm finding that it (the ajax post) doesn't work unless I turn off the cache on the client side. I'm trying to fix this on the server side, but it doesn't seem to be working. I've tried putting this everywhere I can think of: header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past session_start(); I'm not really familiar with how this all works but I read something in the manual which led me to believe that would work. One note is that this is an intranet site, not a www..com site and I don't know whether that changes the script I'm supposed to invoke. Any ideas? Link to comment https://forums.phpfreaks.com/topic/182943-headercache-problem/ Share on other sites More sharing options...
rajivgonsalves Posted November 25, 2009 Share Posted November 25, 2009 what code are you using for the ajax call ? please include a random variable Link to comment https://forums.phpfreaks.com/topic/182943-headercache-problem/#findComment-965613 Share on other sites More sharing options...
simon551 Posted November 25, 2009 Author Share Posted November 25, 2009 Not sure how to include a random variable. function submitStatus(submittype, action){ //alert(submittype+action); var $status = $('#erStatus').text(); var $etmId = $('#etmId').text(); var $access=$('#accesslevel').text(); if(bp==0){if ($access==1){$access=4;}} $.post('../postingfiles/et_statusUpdate.php', { status: $status, etmId: $etmId, access: $access, action:action, submittype:submittype }, function(data){ //alert("Data Loaded: " + data); $('#erStatus').text(data); //run the opening script //alert('trying to get the page to update now'); findstatus(); erStatus(data); } ); if (action=='print'){ print_r(); } if(gotoindex==1){ indexpage=$('#indexpage').text(); //alert(indexpage); window.location=indexpage; } } Link to comment https://forums.phpfreaks.com/topic/182943-headercache-problem/#findComment-965646 Share on other sites More sharing options...
simon551 Posted November 25, 2009 Author Share Posted November 25, 2009 This is the get call, the previous was the post call. $(document).ready(function() { $.getJSON('../sources-json/et-index.php, callback ); }); I did a little checking about random variable and tried this: $(document).ready(function() { var d= Math.floor(Math.random()*50000); $.getJSON('../sources-json/et-index.php?d='+d, callback ); }); Still only works if I disable cache. Link to comment https://forums.phpfreaks.com/topic/182943-headercache-problem/#findComment-965678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.