Re: Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?
| From: | Negin Nickparsa | Date: | Mon, 15 Oct 2012 16:12:09 +0000 |
| Subject: | Re: Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319464@lists.php.net to get a copy of this message | ||
Thanks Tedd,
ajax works fine now,when submiting a button it will show the number and it
doesn't have any problem
$(function() {
$(".button").click(function(){
var id=$(this).attr('id');
var dataString = 'id='+ id ;
$.ajax({
type: "POST",
url: "download_number.php",
data: dataString,
cache: false,
success: function(html)
{
$("#div_"+id).html(html);
} });
}
button:
<input type = "button" value="Download" class="button"
id="<?php echo $id;
?>" >
div:
<div id="div_<?php echo $id; ?>" ><?php echo
$downloadcount;?></div>
by the way* I totally will refuse this approach* because,although the ajax
is working,but I can't do anything for click to download the related file
because when I go to my php page I can't redirect it to a page for download
and besides echo the output to be written in div element,so that,the best
solution is just redirect to a page and download the file in first place.
after submiting write a $_POST['submit'] and just store the download
count,update the table and if user refreshed the page,can see the number of
downloads,*as sure there isn't anything better than this.*
Marco suggested me iframe,reloading it,like a manual ajax but I think it
has much of troubles.
by the way thanks for all helps.