これは、サーバーから画像とデータファイルをダウンロードしている私のphpファイルです
<?php
header("Cache-Control: no-cache, must-revalidate");
//header("Expires: Tue, 25 sep 2012 09:00:00 GMT+5.30");
header("Content-Type: application/xml; charset=utf-8");
clearstatcache();
// download xml.....................................................
$url = "http://ippaddress/msn/getdata.php?result=3";
//echo $url;
$filename = "E://wamp/www/msn_mytype01-12-12/test.xml";
$handle = file_get_contents($url);
file_put_contents($filename, $handle);
$doc = new DOMDocument();
$doc->load( 'test.xml' );
$employees = $doc->getElementsByTagName( "detail" );
foreach( $employees as $employee )
{
$id = $employee->getElementsByTagName( "image" );
$imgid = $id->item(0)->nodeValue;
// download Images.........................
$imageUrl = "http://ippaddress/msn/IMAGE/".$imgid;
$filename = "E://wamp/www/msn_mytype01-12-12/Images/".$imgid;
$handle = file_get_contents($imageUrl);
file_put_contents($filename, $handle);
}
echo('XML Downloded-Successfullyy');
?>
私はj-queryボタンクリックイベントからこのphpファイルを呼び出しています...以下のように
$(document).on('click','#syncdata',function(){
window.location.href="downloadfiles.php";
});
今、私はダウンロードのためにこのファイルを呼び出す必要があり、画像をダウンロードしている間、画像またはプロセスホイール(.gif)ファイルのロードを表示したい.呼ばれている; 私もajaxでこれを試しましたが、画像が表示されません。なぜですか?. このファイルは両方とも同じフォルダーにありますが、ボタンをクリックして画像をダウンロードすると、html/juery ファイルにコールバックせず、プリロードされた .gif 画像が表示されません
以下は、私がajaxを使用して行った方法です
$(document).on('click','#test',function(){
makeRequest();
});
function makeRequest(){
var sendurl={address:'htp://localhost:8082/BMS_mytype/downloadfiles.php'}
$('#preloader').show();
$.ajax({
type:"POST",
url:"dummycall.php",
data:sendurl,
success:function(xml){
alert(xml);
var result= $(xml).find('status').text();
if(result == "Success")
{
$('#preloader').hide();
window.location.href="option.html";
}
callback.call(null);
},
error: function(){
alert("An error occurred while processing XML file.");
} //error ends..
});
$('#preloader').hide();
});