I have built a test app on android using this cool-ass PhoneGap framework, but the problem is the AJAX request can get data from a remote server using jQuery AJAX but once it completes one request the data seems to stick and when I change the response coming from the server, the change is not reflected upon a new request. Here is the AJAX Request in the application itself:
$.getJSON('http://example.com/test1.php', function(data){
alert(data.rec);
});
Here is the PHP code on the remote server:
header('Content-type: application/json');
$arr = array("resp"=>"response has changed");
echo json_encode($arr);
My question is, why? Why won’t the change reflect itself from the application?
In order for jQuery AJAX to not cache the server response on shorthand AJAX requests like
$.getJSON(), you have to setup a global setting that tells subsequent AJAX requests to not cache the server response. You can do this using$.ajaxSetup(). Do it like thisIn order to further prevent caching of server responses use the headers that Tincho Revert posted in his response, they are as follows: