2
我想清除或不寫入緩存url映像,代碼是在ajax上創建的。現在我想顯示圖像,不以高速緩存保存清除剛剛顯示的圖像從緩存上php
的index.php
<html>
<head>
<meta charset="utf-8">
<LINK href="style.css" rel="stylesheet" type="text/css">
<script src="jquery.js"></script>
<script src="script.js"></script>
</head>
<body>
<form id="target" method="get" ENCTYPE="multipart/form-data">
Выберете файл:
<INPUT NAME="myfile" id="myfile" TYPE="file">
<br/>
Time:
<INPUT NAME="time" id="time" TYPE="text" value="10"><br/>
<INPUT TYPE="button" VALUE="Загрузить" onclick="show_info()">
</form>
<div id="result">
</div>
</body>
JS
function getPath(path) {
var finalPath = path.substr(12);
return finalPath; // returns just file name and you can print/put in some input
}
function parse(){
var url = document.getElementById("myfile").value;
var time = document.getElementById("time").value;
url = getPath(url);
$.ajaxSetup({cache: false});
$.get('xml_parsing.php',{url:url,nextelement:k}, function(data) {
$('#result').html(data);
});
}
function show_info(){
setInterval("nextElement()", 5000);
}
function nextElement(){
k++;
parse();
}
和Ajax文件
<?php
$doc = new DOMDocument();
$doc->load($_GET['url']);
$products = $doc->getElementsByTagName("offer");
$id = $_GET['nextelement'];
$offers = $doc->getElementsByTagName("offers");
if($id<$products->length){
$price = $products->item($id)->getElementsByTagName("price");
$name = $products->item($id)->getElementsByTagName("name");
$currency = $products->item($id)->getElementsByTagName("currencyId");
$img = $products->item($id)->getElementsByTagName("picture");
$price_show = $price->item(0)->nodeValue;
$name_show = $name->item(0)->nodeValue;
$img_show = $img->item(0)->nodeValue."?anti_cache=" . rand(0,200);
$currency_show = $currency->item(0)->nodeValue;
echo "<div id='name'>".$name_show."</div>";
echo "<div id='image'><img src=".$img_show." ></div>";
echo "<div id='price'>".$price_show." ".$currency_show."</div>";
}
我怎樣才能做到這一點?我有3個文件。其中的index.php,二線js和AJAX文件
首先,我建議你替換'nodeValue。「?anti_cache =」。 rand(0,200);''by'nodeValue。「?anti_cache =」。 time();'以避免緩存中只有200張圖像。 –
我這樣做,沒什麼.... –