このリクエストの内容は毎日変化します。問題は、キャッシュをクリアするまで、ブラウザー (確かに IE と Chrome) が常に古い結果 (最初に取得したもの) を表示していることです!
どうすればこの問題を解決できますか???
$('#q').keyup(function(){
var param = $(this).val();
if(param == ''){
return
}
if(param != ''){
$('#p_a').html('');
}
$.ajax({
url: 'ajax.php',
data: {qty: param},
type: 'GET',
success: function(result){
$('#p_a').html(result);
},
error: function(result){
$('#p_a').html('Error');
},
});
});
PHP:
<?php
if(isset($_GET['qty'])){
$cq = $_GET['qty'];
$cq = $link->real_escape_string($cq);
$GetP = $link->query("CALL GetPrice($cq)") or die('Query Error');
if(mysqli_num_rows($GetP) === 1){
while($p = mysqli_fetch_array($GetP)){
echo $p['values'];
echo $p['dates'];
}
}else{
echo 'More Rows';
}
}
?>
編集:
このjQuery関数は/正しい/最高の/うまく機能するソリューションですか? ドキュメントから:
cache (default: true, false for dataType 'script' and 'jsonp')
Type: Boolean
If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.