Bonjour,
Quand je clique sur une icone, je voudrais que le fichier soit telecharge:
page1.php:
<a style="cursor: pointer"><img src="<?php echo $path2icons; ?>mp3_yes.png" class="downloadCounter" /></a>
page2.php:
<?php
// traitement de donnee
// insertion a la BD
// incrementer le compteur
$path2mp3 = 'www.site.com/fichier.mp3";
$return_arr["path2mp3"] = $path2mp3;
echo json_encode($return_arr);
// telechargement du fichier
echo '<META HTTP-EQUIV=Refresh CONTENT="1; URL='.$path2mp3.' /">';
?>
index.php:
$('.downloadCounter').click(function(){
// load image
$('.loading').show();
var rub = $('#IDrub').val();
var srub = $('#IDsrub').val();
var cat = $('#IDcat').val();
var scat = $('#IDscat').val();
var menu = $('#IDmenu').val();
var type = $('#IDtype').val();
var num = $('#IDnum').val();
var dataString = '&rub=' + rub + '&srub=' + srub + '&cat=' + cat + '&scat=' + scat + '&menu=' + menu + '&type=' + type + '&num=' + num;
$.ajax({
type: "POST",
url: "page2.php",
data: dataString,
dataType: "json",
success: function(data) {
$(".downloadCounter").html(data.downloadCounterCheck);
}
});
return false;
});
Le fichier ne se lance pas au telechargement, alors j'ai utilise le code
ici, le telechargement se lance mais le compteur JSON ne s'incremente pas au click
merci