我想清楚了,或在高速缓存中的URL图像没有写,在code是创建于阿贾克斯。现在我想显示的图像,并且不保存在缓存中
的index.php
< HTML>
< HEAD>
<元字符集=utf-8>
< LINK HREF =style.css文件相对=样式类型=文本/ CSS>
<脚本SRC =jquery.js和>< / SCRIPT>
&所述;脚本的src =的script.js>&所述; /脚本>
< /头>
<身体GT;
<形式ID =目标的方法=获得ENCTYPE =的multipart / form-data的>
Выберетефайл:
< INPUT NAME =MYFILEID =MYFILETYPE =文件>
< BR />
时间:
< INPUT NAME =时间ID =时间TYPE =文字值=10>< BR />
< INPUT TYPE =按钮VALUE =Загрузить的onclick =show_info()>
< /形式GT;
< DIV ID =结果>
< / DIV>
< /身体GT;
JS
函数getPath(路径){
变种finalPath = path.substr(12);
返回finalPath; //返回刚才的文件名,你可以打印/把一些输入
}
函数parse()的{
VAR URL =的document.getElementById(MYFILE)值。
。VAR时间=的document.getElementById(时代)的价值;
URL = getPath(URL);
$ .ajaxSetup({缓存:假});
$获得('xml_parsing.php',{网址:网址,nextelement:K},功能(数据){
$('#结果)HTML(数据)。
});
}
功能show_info(){
的setInterval(nextElement(),5000);
}
传播nextElement(){
ķ++;
解析();
}
和AJAX文件
< PHP
$ DOC =新的DOMDocument();
$ doc->负载($ _ GET ['URL']);
$产品= $ doc->的getElementsByTagName(要约);
的$ id = $ _GET ['nextelement'];
$提供= $ doc->的getElementsByTagName(报价);
如果($ ID< $产品 - >长度){
$价格= $产品 - >项目($ ID) - >的getElementsByTagName(代价);
$ NAME = $产品 - >项目($ ID) - >的getElementsByTagName(姓名);
$货币= $产品 - >项目($ ID) - >的getElementsByTagName(currencyId);
$ IMG = $产品 - >项目($ ID) - >的getElementsByTagName(图片);
$ price_show = $价格 - >项目(0) - >的nodeValue;
$ name_show = $名字 - >项目(0) - >的nodeValue;
$ img_show = $ img->项(0) - >?anti_cache =的nodeValue。兰特(0,200);
$ currency_show = $ currency->项(0) - >的nodeValue;
回声< DIV ID ='名'>中$ name_show。< / DIV>中;
回声< DIV ID ='形象'>< IMG SRC =$ img_show。>< / DIV>中;
回声< DIV ID ='价格'>中$ price_show&LT。$ currency_show。; / DIV>中;
}
我怎样才能做到这一点?我有3个文件。其中的index.php,第二JS和Ajax文件
解决方案在这一行:
$得到('xml_parsing.php',{网址:网址,nextelement:K},功能(数据){
将其更改为:
$.get('xml_parsing.php?anti_cache='+Math.floor(Math.random()*1000),{url:url,nextelement:k},功能(数据){这将确保所请求的页面不变得容易缓存。
希望有所帮助: - )
。I would like to clear or no write in cache url image, the code was create on ajax . Now I would like to show image and don't save in cache
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();
}
and ajax file
<?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>";
}
How can I do this? I have 3 files. One index.php, second- js and ajax file
解决方案On this line:
$.get('xml_parsing.php',{url:url,nextelement:k}, function(data) {
Change it to:
$.get('xml_parsing.php?anti_cache='+Math.floor(Math.random()*1000),{url:url,nextelement:k}, function(data) {
This will make sure the page that is requested does not become cached easily.
Hope that helps :-).